FABLESLIP commited on
Commit
33650b0
·
verified ·
1 Parent(s): 672687a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -29,6 +29,8 @@ print(f"[BOOT] POINTER_URL={POINTER_URL or '(unset)'}")
29
  print(f"[BOOT] FALLBACK_BASE={FALLBACK_BASE}")
30
  _backend_url_cache = {"url": None, "ts": 0.0}
31
 
 
 
32
 
33
  # --- Instance ID (utile si plusieurs répliques derrière un proxy) -------------
34
  INSTANCE_ID = os.getenv("INSTANCE_ID", uuid.uuid4().hex[:6])
@@ -43,8 +45,6 @@ async def inject_instance_id_header(request: Request, call_next):
43
  return resp
44
  # ------------------------------------------------------------------------------
45
 
46
-
47
-
48
  def get_backend_base() -> str:
49
  try:
50
  if POINTER_URL:
@@ -63,7 +63,6 @@ def get_backend_base() -> str:
63
  except Exception:
64
  return FALLBACK_BASE
65
 
66
- app = FastAPI(title="Video Editor API", version="0.5.9")
67
  DATA_DIR = Path("/app/data")
68
  THUMB_DIR = DATA_DIR / "_thumbs"
69
  MASK_DIR = DATA_DIR / "_masks"
@@ -73,6 +72,7 @@ for p in (DATA_DIR, THUMB_DIR, MASK_DIR):
73
  app.mount("/data", StaticFiles(directory=str(DATA_DIR)), name="data")
74
  app.mount("/thumbs", StaticFiles(directory=str(THUMB_DIR)), name="thumbs")
75
 
 
76
  # --- PROXY VERS LE BACKEND (pas de CORS côté navigateur) --------------------
77
  @app.api_route("/p/{full_path:path}", methods=["GET","POST","PUT","PATCH","DELETE","OPTIONS"])
78
  async def proxy_all(full_path: str, request: Request):
 
29
  print(f"[BOOT] FALLBACK_BASE={FALLBACK_BASE}")
30
  _backend_url_cache = {"url": None, "ts": 0.0}
31
 
32
+ # <<< IMPORTANT : créer l'app AVANT tout décorateur @app.* >>>
33
+ app = FastAPI(title="Video Editor API", version="0.5.9")
34
 
35
  # --- Instance ID (utile si plusieurs répliques derrière un proxy) -------------
36
  INSTANCE_ID = os.getenv("INSTANCE_ID", uuid.uuid4().hex[:6])
 
45
  return resp
46
  # ------------------------------------------------------------------------------
47
 
 
 
48
  def get_backend_base() -> str:
49
  try:
50
  if POINTER_URL:
 
63
  except Exception:
64
  return FALLBACK_BASE
65
 
 
66
  DATA_DIR = Path("/app/data")
67
  THUMB_DIR = DATA_DIR / "_thumbs"
68
  MASK_DIR = DATA_DIR / "_masks"
 
72
  app.mount("/data", StaticFiles(directory=str(DATA_DIR)), name="data")
73
  app.mount("/thumbs", StaticFiles(directory=str(THUMB_DIR)), name="thumbs")
74
 
75
+
76
  # --- PROXY VERS LE BACKEND (pas de CORS côté navigateur) --------------------
77
  @app.api_route("/p/{full_path:path}", methods=["GET","POST","PUT","PATCH","DELETE","OPTIONS"])
78
  async def proxy_all(full_path: str, request: Request):