]> OzVa Git service - critters-api/commitdiff
Fixed template paths
authorMax Value <greenwoodw50@gmail.com>
Mon, 9 Dec 2024 07:08:13 +0000 (07:08 +0000)
committerMax Value <greenwoodw50@gmail.com>
Mon, 9 Dec 2024 07:15:01 +0000 (07:15 +0000)
critters.py

index 78594c78217b735515604db15e78d972b69c2265..399163bdb23a64f6f95edb16f4f733420efda414 100755 (executable)
@@ -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