removing app_root in flask routes
This commit is contained in:
parent
7fb3e4adee
commit
4bb1c14abe
18
octomode.py
18
octomode.py
@ -97,7 +97,7 @@ def get_md_metadata(md_pad_content):
|
||||
|
||||
# ---
|
||||
|
||||
@APP.route(APP.config["APPLICATION_ROOT"], methods=['GET', 'POST'])
|
||||
@APP.route('/', methods=['GET', 'POST'])
|
||||
def index():
|
||||
name = False
|
||||
if request.values.get('name'):
|
||||
@ -112,28 +112,28 @@ def index():
|
||||
else:
|
||||
return render_template('start.html', application_root=APP.config["APPLICATION_ROOT"])
|
||||
|
||||
@APP.route(f'{ APP.config["APPLICATION_ROOT"] }/<name>/')
|
||||
@APP.route('/<name>/')
|
||||
def main(name):
|
||||
return redirect(url_for('pad', name=name))
|
||||
|
||||
@APP.route(f'{ APP.config["APPLICATION_ROOT"] }/<name>/pad/')
|
||||
@APP.route('/<name>/pad/')
|
||||
def pad(name):
|
||||
pad_name = f'{ name }.md'
|
||||
url = os.path.join(APP.config['PAD_URL'], pad_name)
|
||||
return render_template('iframe.html', url=url, name=name.strip())
|
||||
|
||||
@APP.route(f'{ APP.config["APPLICATION_ROOT"] }/<name>/stylesheet/')
|
||||
@APP.route('/<name>/stylesheet/')
|
||||
def stylesheet(name):
|
||||
pad_name = f'{ name }.css'
|
||||
url = os.path.join(APP.config['PAD_URL'], pad_name)
|
||||
return render_template('iframe.html', url=url, name=name.strip())
|
||||
|
||||
@APP.route(f'{ APP.config["APPLICATION_ROOT"] }/<name>/html/')
|
||||
@APP.route('/<name>/html/')
|
||||
def html(name):
|
||||
path = os.path.join(f'/{ name }/', 'preview.html')
|
||||
return render_template('iframe.html', url=path, name=name.strip())
|
||||
|
||||
@APP.route(f'{ APP.config["APPLICATION_ROOT"] }/<name>/pdf/')
|
||||
@APP.route('/<name>/pdf/')
|
||||
def pdf(name):
|
||||
path = os.path.join(f'/{ name }/', 'pagedjs.html')
|
||||
return render_template('pdf.html', url=path, name=name.strip())
|
||||
@ -143,14 +143,14 @@ def pdf(name):
|
||||
# //////////////////
|
||||
# (These are not saved as a file on the server)
|
||||
|
||||
@APP.route(f'{ APP.config["APPLICATION_ROOT"] }/<name>/stylesheet.css')
|
||||
@APP.route('/<name>/stylesheet.css')
|
||||
def css(name):
|
||||
css = get_pad_content(name, '.css')
|
||||
# Insert CSS sanitizer here.
|
||||
|
||||
return css, 200, {'Content-Type': 'text/css; charset=utf-8'}
|
||||
|
||||
@APP.route(f'{ APP.config["APPLICATION_ROOT"] }/<name>/preview.html')
|
||||
@APP.route('/<name>/preview.html')
|
||||
def preview(name):
|
||||
# TO GENERATE THE PREVIEW WEBPAGE
|
||||
md_pad_content = get_pad_content(name, ext='.md')
|
||||
@ -161,7 +161,7 @@ def preview(name):
|
||||
|
||||
return render_template('preview.html', name=name.strip(), pad_content=html, lang=lang, title=title)
|
||||
|
||||
@APP.route(f'{ APP.config["APPLICATION_ROOT"] }/<name>/pagedjs.html')
|
||||
@APP.route('/<name>/pagedjs.html')
|
||||
def pagedjs(name):
|
||||
# TO GENERATE THE PAGED.JS WEBPAGE
|
||||
md_pad_content = get_pad_content(name, ext='.md')
|
||||
|
Loading…
Reference in New Issue
Block a user