diff --git a/Flask/app.py b/Flask/app.py index b25aace..e587ea1 100644 --- a/Flask/app.py +++ b/Flask/app.py @@ -90,25 +90,17 @@ def update_jobs(): print(e) -def edit_version(): - with open("/app/MsRewards-Reborn/version", "r") as f: - version = f.readline().replace("\n", '') - f = open("/app/MsRewards-Reborn/Flask/templates/base.html", "r") - txt = f.readlines() - f.close() - f = open("/app/MsRewards-Reborn/Flask/templates/base.html", "w") - for i in txt: - i = re.sub('
', f' ', i) - f.write(i) - f.close() - - """ #Flask app """ app = Flask(__name__) +@app.context_processor +def inject_default_variables(): + with open("/app/MsRewards-Reborn/version", "r") as f: + version = f.readline().replace("\n", '') + return dict(version=version) """ #Login stuff """ @@ -167,7 +159,7 @@ def change_password(): # handle login failed @app.errorhandler(401) def unauthorized(e): - return(render_template("login.html")) + return(redirect("login")) # callback to reload the user object @@ -292,7 +284,6 @@ def proxy_post(): @app.route("/override/") def override_get(): - edit_version() with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile: configs = json.load(inFile) return(render_template("override.html", data=configs)) @@ -300,7 +291,6 @@ def override_get(): @app.route("/override/", methods=["post"]) def override_post(): - edit_version() with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile: configs = json.load(inFile) @@ -373,6 +363,10 @@ def logs(): print(configs) return(render_template("logs.html", data=configs)) +@app.route("/stats/", methods=["GET", "POST"]) +def stats(): + return(render_template("stats.html")) + @app.route('/download/