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():
|
def index():
|
||||||
name = False
|
name = False
|
||||||
if request.values.get('name'):
|
if request.values.get('name'):
|
||||||
@ -112,28 +112,28 @@ def index():
|
|||||||
else:
|
else:
|
||||||
return render_template('start.html', application_root=APP.config["APPLICATION_ROOT"])
|
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):
|
def main(name):
|
||||||
return redirect(url_for('pad', name=name))
|
return redirect(url_for('pad', name=name))
|
||||||
|
|
||||||
@APP.route(f'{ APP.config["APPLICATION_ROOT"] }/<name>/pad/')
|
@APP.route('/<name>/pad/')
|
||||||
def pad(name):
|
def pad(name):
|
||||||
pad_name = f'{ name }.md'
|
pad_name = f'{ name }.md'
|
||||||
url = os.path.join(APP.config['PAD_URL'], pad_name)
|
url = os.path.join(APP.config['PAD_URL'], pad_name)
|
||||||
return render_template('iframe.html', url=url, name=name.strip())
|
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):
|
def stylesheet(name):
|
||||||
pad_name = f'{ name }.css'
|
pad_name = f'{ name }.css'
|
||||||
url = os.path.join(APP.config['PAD_URL'], pad_name)
|
url = os.path.join(APP.config['PAD_URL'], pad_name)
|
||||||
return render_template('iframe.html', url=url, name=name.strip())
|
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):
|
def html(name):
|
||||||
path = os.path.join(f'/{ name }/', 'preview.html')
|
path = os.path.join(f'/{ name }/', 'preview.html')
|
||||||
return render_template('iframe.html', url=path, name=name.strip())
|
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):
|
def pdf(name):
|
||||||
path = os.path.join(f'/{ name }/', 'pagedjs.html')
|
path = os.path.join(f'/{ name }/', 'pagedjs.html')
|
||||||
return render_template('pdf.html', url=path, name=name.strip())
|
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)
|
# (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):
|
def css(name):
|
||||||
css = get_pad_content(name, '.css')
|
css = get_pad_content(name, '.css')
|
||||||
# Insert CSS sanitizer here.
|
# Insert CSS sanitizer here.
|
||||||
|
|
||||||
return css, 200, {'Content-Type': 'text/css; charset=utf-8'}
|
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):
|
def preview(name):
|
||||||
# TO GENERATE THE PREVIEW WEBPAGE
|
# TO GENERATE THE PREVIEW WEBPAGE
|
||||||
md_pad_content = get_pad_content(name, ext='.md')
|
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)
|
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):
|
def pagedjs(name):
|
||||||
# TO GENERATE THE PAGED.JS WEBPAGE
|
# TO GENERATE THE PAGED.JS WEBPAGE
|
||||||
md_pad_content = get_pad_content(name, ext='.md')
|
md_pad_content = get_pad_content(name, ext='.md')
|
||||||
|
Loading…
Reference in New Issue
Block a user