From 7fb3e4adee640c345afcdd9eb8f08aa75a0846e4 Mon Sep 17 00:00:00 2001 From: manetta Date: Fri, 11 Mar 2022 17:05:47 +0100 Subject: [PATCH] adding missing url_for --- octomode.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/octomode.py b/octomode.py index f4b7025..5604d53 100755 --- a/octomode.py +++ b/octomode.py @@ -1,6 +1,6 @@ import os import json -from flask import Flask, request, render_template, redirect +from flask import Flask, request, render_template, redirect, url_for from urllib.request import urlopen from urllib.parse import urlencode @@ -97,7 +97,7 @@ def get_md_metadata(md_pad_content): # --- -@APP.route('/', methods=['GET', 'POST']) +@APP.route(APP.config["APPLICATION_ROOT"], methods=['GET', 'POST']) def index(): name = False if request.values.get('name'): @@ -110,30 +110,30 @@ def index(): create_pad_on_first_run(name, ext) return redirect(url_for('pad', name=name)) 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('//') +@APP.route(f'{ APP.config["APPLICATION_ROOT"] }//') def main(name): return redirect(url_for('pad', name=name)) -@APP.route('//pad/') +@APP.route(f'{ APP.config["APPLICATION_ROOT"] }//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('//stylesheet/') +@APP.route(f'{ APP.config["APPLICATION_ROOT"] }//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('//html/') +@APP.route(f'{ APP.config["APPLICATION_ROOT"] }//html/') def html(name): path = os.path.join(f'/{ name }/', 'preview.html') return render_template('iframe.html', url=path, name=name.strip()) -@APP.route('//pdf/') +@APP.route(f'{ APP.config["APPLICATION_ROOT"] }//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('//stylesheet.css') +@APP.route(f'{ APP.config["APPLICATION_ROOT"] }//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('//preview.html') +@APP.route(f'{ APP.config["APPLICATION_ROOT"] }//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('//pagedjs.html') +@APP.route(f'{ APP.config["APPLICATION_ROOT"] }//pagedjs.html') def pagedjs(name): # TO GENERATE THE PAGED.JS WEBPAGE md_pad_content = get_pad_content(name, ext='.md')