diff --git a/app.py b/app.py index 2841054..d94a23e 100644 --- a/app.py +++ b/app.py @@ -1,13 +1,29 @@ from flask import Flask, render_template, jsonify from datetime import datetime, timezone, timedelta import os +import sys from dotenv import load_dotenv load_dotenv() from clients import jellyfin -app = Flask(__name__, template_folder=os.path.join(os.path.dirname(__file__), 'templates')) +def _find_template_folder(): + candidates = [ + os.path.join(os.path.dirname(__file__), 'templates'), + os.path.join(os.path.dirname(sys.executable), '..', 'Resources', 'templates'), + os.path.join(os.getcwd(), 'templates'), + ] + for p in candidates: + try: + p_norm = os.path.normpath(os.path.abspath(p)) + if os.path.isdir(p_norm): + return p_norm + except Exception: + continue + return os.path.join(os.path.dirname(__file__), 'templates') + +app = Flask(__name__, template_folder=_find_template_folder()) PHT = timezone(timedelta(hours=8))