FABLESLIP commited on
Commit
a701adb
·
verified ·
1 Parent(s): e146039

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -10
app.py CHANGED
@@ -8,7 +8,13 @@ from fastapi.responses import HTMLResponse, FileResponse, RedirectResponse
8
  from fastapi.staticfiles import StaticFiles
9
  from pathlib import Path
10
  from typing import Optional, Dict, Any
11
- import uuid, shutil, cv2, json, time, urllib.parse, sys
 
 
 
 
 
 
12
  import threading
13
  # <<<< HUGINFACE PATCH: WARMUP IMPORTS START >>>>
14
  from typing import List
@@ -23,6 +29,7 @@ import os
23
  import httpx
24
 
25
  print("[BOOT] Video Editor API starting…")
 
26
  POINTER_URL = os.getenv("BACKEND_POINTER_URL", "").strip()
27
  FALLBACK_BASE = os.getenv("BACKEND_BASE_URL", "http://127.0.0.1:8765").strip()
28
  print(f"[BOOT] POINTER_URL={POINTER_URL or '(unset)'}")
@@ -156,14 +163,19 @@ def _default_model_list() -> List[str]:
156
 
157
  def _log_warmup(msg: str):
158
  # >>> ICONES LOGS (ajout) <<<
159
- if msg.startswith("[CACHE]"): msg = "⬛ " + msg # ignoré: déjà en cache
160
- elif msg.startswith("[START]"): msg = " " + msg # démarrage d'un dépôt
161
- elif msg.startswith("[DONE]"): msg = "✅ " + msg # téléchargement OK
162
- elif msg.startswith("[FAIL]"): msg = " " + msg # échec
163
- elif msg.startswith("[STOP]"): msg = "⏹️ " + msg # arrêt demandé
164
- # >>> FIN AJOUT <<<
 
 
 
 
165
 
166
  print(f"[WARMUP] {msg}", file=sys.stdout)
 
167
  with warmup_lock:
168
  warmup_state["logs"].append(msg)
169
  if len(warmup_state["logs"]) > 400:
@@ -2052,8 +2064,8 @@ document.head.appendChild(style);
2052
  def ui(v: Optional[str] = "", msg: Optional[str] = ""):
2053
  vid = v or ""
2054
  try:
2055
- msg = urllib.parse.unquote(msg or "")
2056
  except Exception:
2057
- pass
2058
- html = HTML_TEMPLATE.replace("__VID__", urllib.parse.quote(vid)).replace("__MSG__", msg)
2059
  return HTMLResponse(content=html)
 
8
  from fastapi.staticfiles import StaticFiles
9
  from pathlib import Path
10
  from typing import Optional, Dict, Any
11
+ import uuid
12
+ import shutil
13
+ import cv2
14
+ import json
15
+ import time
16
+ import urllib.parse
17
+ import sys
18
  import threading
19
  # <<<< HUGINFACE PATCH: WARMUP IMPORTS START >>>>
20
  from typing import List
 
29
  import httpx
30
 
31
  print("[BOOT] Video Editor API starting…")
32
+ from copy import deepcopy
33
  POINTER_URL = os.getenv("BACKEND_POINTER_URL", "").strip()
34
  FALLBACK_BASE = os.getenv("BACKEND_BASE_URL", "http://127.0.0.1:8765").strip()
35
  print(f"[BOOT] POINTER_URL={POINTER_URL or '(unset)'}")
 
163
 
164
  def _log_warmup(msg: str):
165
  # >>> ICONES LOGS (ajout) <<<
166
+ if msg.startswith("[CACHE]"):
167
+ msg = " " + msg # ignoré: déjà en cache
168
+ elif msg.startswith("[START]"):
169
+ msg = " " + msg # démarrage d'un dépôt
170
+ elif msg.startswith("[DONE]"):
171
+ msg = "✅ " + msg # téléchargement OK
172
+ elif msg.startswith("[FAIL]"):
173
+ msg = "❌ " + msg # échec
174
+ elif msg.startswith("[STOP]"):
175
+ msg = "⏹️ " + msg # arrêt demandé
176
 
177
  print(f"[WARMUP] {msg}", file=sys.stdout)
178
+
179
  with warmup_lock:
180
  warmup_state["logs"].append(msg)
181
  if len(warmup_state["logs"]) > 400:
 
2064
  def ui(v: Optional[str] = "", msg: Optional[str] = ""):
2065
  vid = v or ""
2066
  try:
2067
+ safe_msg: str = urllib.parse.unquote(msg or "")
2068
  except Exception:
2069
+ safe_msg = ""
2070
+ html = HTML_TEMPLATE.replace("__VID__", urllib.parse.quote(vid)).replace("__MSG__", safe_msg)
2071
  return HTMLResponse(content=html)