m-newhauser commited on
Commit
a2d5213
·
verified ·
1 Parent(s): 07e60da

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. app.py +14 -3
  2. static/assets/.gitkeep +0 -0
app.py CHANGED
@@ -16,6 +16,10 @@ import model
16
 
17
  APP_DIR = os.path.dirname(os.path.abspath(__file__))
18
  STATIC = os.path.join(APP_DIR, "static")
 
 
 
 
19
 
20
  _LOCK = threading.Lock() # one inference at a time: CPU threads beat concurrency
21
 
@@ -33,12 +37,19 @@ def index():
33
 
34
  @app.route("/<path:name>")
35
  def static_file(name):
36
- # Shared chrome + demo assets. Anything in static/assets/ is served; keep
37
- # user-added images there to avoid editing this whitelist.
38
  if name in ("brand.css", "strip.js", "favicon.svg", "og-card.png"):
39
  return send_from_directory(STATIC, name)
40
  if name.startswith("assets/"):
41
- return send_from_directory(STATIC, name)
 
 
 
 
 
 
 
42
  return ("not found", 404)
43
 
44
 
 
16
 
17
  APP_DIR = os.path.dirname(os.path.abspath(__file__))
18
  STATIC = os.path.join(APP_DIR, "static")
19
+ # Shared kit-wide assets live in gliner2.5-demo-kit/assets/. Demo-local overrides
20
+ # can be dropped in demos/<name>/static/assets/ and win over shared files of the
21
+ # same name. URL space is the same: GET /assets/<rel>.
22
+ KIT_ASSETS = os.path.abspath(os.path.join(APP_DIR, "..", "..", "assets"))
23
 
24
  _LOCK = threading.Lock() # one inference at a time: CPU threads beat concurrency
25
 
 
37
 
38
  @app.route("/<path:name>")
39
  def static_file(name):
40
+ # Shared chrome + demo assets. Anything in static/assets/ is served from the
41
+ # demo-local dir first; falls back to kit-root assets/ for shared files.
42
  if name in ("brand.css", "strip.js", "favicon.svg", "og-card.png"):
43
  return send_from_directory(STATIC, name)
44
  if name.startswith("assets/"):
45
+ rel = name[len("assets/"):]
46
+ demo_local = os.path.join(STATIC, "assets", rel)
47
+ if os.path.isfile(demo_local):
48
+ return send_from_directory(os.path.join(STATIC, "assets"), rel)
49
+ kit_shared = os.path.join(KIT_ASSETS, rel)
50
+ if os.path.isfile(kit_shared):
51
+ return send_from_directory(KIT_ASSETS, rel)
52
+ return ("not found", 404)
53
  return ("not found", 404)
54
 
55
 
static/assets/.gitkeep ADDED
File without changes