Upload folder using huggingface_hub
Browse files- app.py +14 -3
- 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
|
| 37 |
-
#
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|