Spaces:
Sleeping
Sleeping
Commit
·
79e8250
1
Parent(s):
e50b5e7
hhh
Browse files- gradio_interface.py +22 -1
gradio_interface.py
CHANGED
|
@@ -483,7 +483,28 @@ text
|
|
| 483 |
inputs=[download_btn],
|
| 484 |
outputs=[download_btn]
|
| 485 |
)
|
| 486 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 487 |
return demo
|
| 488 |
|
| 489 |
# Export the interface creation function
|
|
|
|
| 483 |
inputs=[download_btn],
|
| 484 |
outputs=[download_btn]
|
| 485 |
)
|
| 486 |
+
# Attach middleware to handle root pings like '/?logs=container&__theme=system' with 200 OK
|
| 487 |
+
try:
|
| 488 |
+
app = demo.app
|
| 489 |
+
from starlette.middleware.base import BaseHTTPMiddleware
|
| 490 |
+
from starlette.responses import PlainTextResponse
|
| 491 |
+
|
| 492 |
+
class RootQueryOkMiddleware(BaseHTTPMiddleware):
|
| 493 |
+
async def dispatch(self, request, call_next):
|
| 494 |
+
try:
|
| 495 |
+
if request.url.path == "/":
|
| 496 |
+
qp = request.query_params
|
| 497 |
+
if "logs" in qp or "__theme" in qp:
|
| 498 |
+
return PlainTextResponse("ok")
|
| 499 |
+
except Exception:
|
| 500 |
+
pass
|
| 501 |
+
return await call_next(request)
|
| 502 |
+
|
| 503 |
+
app.add_middleware(RootQueryOkMiddleware)
|
| 504 |
+
except Exception:
|
| 505 |
+
# Non-fatal; UI still works even if middleware can't be added
|
| 506 |
+
pass
|
| 507 |
+
|
| 508 |
return demo
|
| 509 |
|
| 510 |
# Export the interface creation function
|