From 1d20d332f6dcc0978c5ba686ce8f69fdef7b8c84 Mon Sep 17 00:00:00 2001 From: Max Value Date: Mon, 9 Dec 2024 07:08:13 +0000 Subject: [PATCH] Fixed template paths --- critters.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/critters.py b/critters.py index 78594c7..399163b 100755 --- a/critters.py +++ b/critters.py @@ -1,6 +1,6 @@ #! .venv/bin/python3 -from flask import Flask, Response, request, render_template, redirect, send_from_directory, url_for +from flask import Flask, Response, request, render_template_string, redirect, send_from_directory, url_for from flask_httpauth import HTTPBasicAuth from werkzeug.security import generate_password_hash, check_password_hash from werkzeug.middleware.proxy_fix import ProxyFix @@ -28,6 +28,7 @@ audio_path = "/home/stream/critters/audio/" cover_path = "/home/stream/critters/cover/" icon_path = "/home/stream/critters/icon/" upload_path = "/home/stream/critters/upload/" +template_path = "/home/stream/critters/critters-api/templates/" def check_files(track_id): return { @@ -55,7 +56,8 @@ def verify_password(username, password): # Homepage @app.route("/") def homepage(): - page = render_template("home.html") + with open(template_path + "home.html","r") as f: + page = render_template_string(f.read()) return Response(page, mimetype="text/html") # Admin pannel @@ -74,8 +76,6 @@ def admin(): else: playing = "false" - print(playing) - # Get the new track id if neccicary if commit_id == 0: tracks = cur.execute(f"SELECT id FROM critters").fetchall() @@ -165,7 +165,8 @@ def admin(): os.system(f"convert {file_path} -scale 32x32! {icon_path}{commit_id}.png &") os.system(f"convert {file_path} -scale 600x600! {cover_path}{commit_id}.png &") - page = render_template("admin.html", user = auth.current_user()) + with open(template_path + "admin.html", "r") as f: + page = render_template_string(f.read(), user = auth.current_user()) return Response(page, mimetype="text/html") # Get the next track -- 2.39.2