소스 검색

Resolve structuring for install variences

ArtyomV2X 3 주 전
부모
커밋
303339cd9e
1개의 변경된 파일12개의 추가작업 그리고 10개의 파일을 삭제
  1. 12 10
      app.py

+ 12 - 10
app.py

@@ -42,7 +42,7 @@ for d in (UPLOAD_DIR, OUTPUT_DIR, JOBS_DIR):
     d.mkdir(parents=True, exist_ok=True)
 
 HANDBRAKE = shutil.which("HandBrakeCLI") or "/usr/bin/HandBrakeCLI"
-VERSION   = "1.0.2"
+VERSION   = "1.0.3"
 
 def load_tokens():
     """token.json is created by install.sh and is never part of the repo."""
@@ -461,15 +461,17 @@ threading.Thread(target=worker_loop, daemon=True).start()
 # --------------------------------------------------------------------------
 @app.route("/")
 def index():
-    page = STATIC_DIR / "index.html"
-    if not page.is_file() or page.stat().st_size == 0:
-        return jsonify({
-            "error": "WeBrake backend is running, but the UI file is missing.",
-            "expected": str(page),
-            "fix": "Run /opt/webrake/update.sh to pull static/index.html from the repo, "
-                   "or place the file there manually, then reload this page.",
-        }), 503
-    return send_from_directory(STATIC_DIR, "index.html")
+    # Accept either layout: static/index.html (canonical) or a flat
+    # /opt/webrake/index.html (as older updaters installed it).
+    for candidate in (STATIC_DIR / "index.html", APP_DIR / "index.html"):
+        if candidate.is_file() and candidate.stat().st_size > 0:
+            return send_from_directory(candidate.parent, candidate.name)
+    return jsonify({
+        "error": "WeBrake backend is running, but the UI file is missing.",
+        "looked_in": [str(STATIC_DIR / "index.html"), str(APP_DIR / "index.html")],
+        "fix": "Run /opt/webrake/update.sh to pull index.html from the repo, "
+               "or place the file at either path, then reload this page.",
+    }), 503
 
 @app.route("/<path:anything>")
 def catch_all(anything):