From 4c7b60b99a5a985f508de879902db7a313aecec7 Mon Sep 17 00:00:00 2001 From: Jarian Cottingham Date: Mon, 2 Feb 2026 08:20:21 -0600 Subject: [PATCH] Simplify path resolution for static files in Flask app --- src/server/app.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/server/app.py b/src/server/app.py index 69c00de..d8f2e67 100644 --- a/src/server/app.py +++ b/src/server/app.py @@ -5,9 +5,6 @@ import os app = Flask(__name__) CORS(app) # Enable CORS for all routes -# Get the directory where this script is located -script_dir = os.path.dirname(os.path.abspath(__file__)) - # Import our archive parser from parse_archive import ArchiveParser @@ -16,18 +13,20 @@ archive_parser = ArchiveParser() # Serve static files from the website directory +# The website directory is at the same level as the src directory @app.route("/") def serve_static(filename): - # Use absolute path to website directory - website_dir = os.path.join(script_dir, "..", "website") + # In Docker, the structure is: /app/src/server/ and /app/website/ + # So we need to go up from src/server to /app/ and then to /app/website + website_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "website") return send_from_directory(website_dir, filename) # Serve the main index.html page @app.route("/") def serve_index(): - # Use absolute path to website directory - website_dir = os.path.join(script_dir, "..", "website") + # In Docker, the structure is: /app/src/server/ and /app/website/ + website_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "website") return send_from_directory(website_dir, "index.html")