Mehdi commited on
Commit ·
2d50118
1
Parent(s): 008db30
fix: inject /blog into Gradio's internal FastAPI router at position 0
Browse filesgr.mount_gradio_app + uvicorn was ignored by HF Spaces (expects demo.launch).
Use prevent_thread_lock=True to get the live FastAPI app, then insert the
static-files Mount at index 0 so it is checked before Gradio's catch-all.
app.py
CHANGED
|
@@ -1077,9 +1077,15 @@ with gr.Blocks(title="PaperProf", css=CSS) as demo:
|
|
| 1077 |
print("✅ Gradio demo defined successfully")
|
| 1078 |
|
| 1079 |
print("✅ Launching demo...")
|
| 1080 |
-
|
| 1081 |
-
|
| 1082 |
-
|
| 1083 |
-
|
| 1084 |
-
|
| 1085 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1077 |
print("✅ Gradio demo defined successfully")
|
| 1078 |
|
| 1079 |
print("✅ Launching demo...")
|
| 1080 |
+
app, local_url, _ = demo.launch(
|
| 1081 |
+
server_name="0.0.0.0",
|
| 1082 |
+
server_port=7860,
|
| 1083 |
+
prevent_thread_lock=True,
|
| 1084 |
+
)
|
| 1085 |
+
|
| 1086 |
+
# Insert /blog BEFORE Gradio's catch-all route so it takes priority
|
| 1087 |
+
from starlette.routing import Mount
|
| 1088 |
+
app.router.routes.insert(0, Mount("/blog", StaticFiles(directory="blog", html=True), name="blog"))
|
| 1089 |
+
print(f"✅ Blog mounted at {local_url}blog")
|
| 1090 |
+
|
| 1091 |
+
demo.block_thread()
|