Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- server/app.py +6 -5
- tests/smoke/test_ingestion_api.py +9 -8
server/app.py
CHANGED
|
@@ -347,10 +347,11 @@ async def scalar_ui(request: Request) -> HTMLResponse: # noqa: ARG001
|
|
| 347 |
return HTMLResponse(_SCALAR_HTML)
|
| 348 |
|
| 349 |
|
| 350 |
-
@app.get("/", include_in_schema=False)
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
|
|
|
| 354 |
|
| 355 |
|
| 356 |
@app.get("/healthz", response_model=HealthResponse)
|
|
@@ -528,7 +529,7 @@ async def analyze_ingestion(request: AnalyzeIngestionRequest) -> AnalyzeIngestio
|
|
| 528 |
|
| 529 |
|
| 530 |
_gradio_workspace = build_gradio_workspace()
|
| 531 |
-
app = gr.mount_gradio_app(app, _gradio_workspace, path="/
|
| 532 |
|
| 533 |
|
| 534 |
def main() -> None:
|
|
|
|
| 347 |
return HTMLResponse(_SCALAR_HTML)
|
| 348 |
|
| 349 |
|
| 350 |
+
@app.get("/ui", include_in_schema=False)
|
| 351 |
+
@app.get("/ui/", include_in_schema=False)
|
| 352 |
+
async def legacy_ui_path() -> RedirectResponse:
|
| 353 |
+
"""Backwards-compatible redirect from the old /ui path to the root page."""
|
| 354 |
+
return RedirectResponse(url="/")
|
| 355 |
|
| 356 |
|
| 357 |
@app.get("/healthz", response_model=HealthResponse)
|
|
|
|
| 529 |
|
| 530 |
|
| 531 |
_gradio_workspace = build_gradio_workspace()
|
| 532 |
+
app = gr.mount_gradio_app(app, _gradio_workspace, path="/")
|
| 533 |
|
| 534 |
|
| 535 |
def main() -> None:
|
tests/smoke/test_ingestion_api.py
CHANGED
|
@@ -34,18 +34,19 @@ def test_health_endpoint_returns_status():
|
|
| 34 |
assert payload["status"] in {"ok", "healthy"}
|
| 35 |
|
| 36 |
|
| 37 |
-
def
|
| 38 |
-
response = client.get("/", follow_redirects=
|
| 39 |
|
| 40 |
-
assert response.status_code
|
| 41 |
-
assert response.headers
|
|
|
|
| 42 |
|
| 43 |
|
| 44 |
-
def
|
| 45 |
-
response = client.get("/ui/", follow_redirects=
|
| 46 |
|
| 47 |
-
assert response.status_code
|
| 48 |
-
assert
|
| 49 |
|
| 50 |
|
| 51 |
def test_healthz_endpoint_returns_versioned_ok():
|
|
|
|
| 34 |
assert payload["status"] in {"ok", "healthy"}
|
| 35 |
|
| 36 |
|
| 37 |
+
def test_root_serves_gradio_ui():
|
| 38 |
+
response = client.get("/", follow_redirects=True)
|
| 39 |
|
| 40 |
+
assert response.status_code == 200
|
| 41 |
+
assert "text/html" in response.headers.get("content-type", "")
|
| 42 |
+
assert "TalkingHeadBench Workspace" in response.text
|
| 43 |
|
| 44 |
|
| 45 |
+
def test_legacy_ui_path_redirects_to_root():
|
| 46 |
+
response = client.get("/ui/", follow_redirects=False)
|
| 47 |
|
| 48 |
+
assert response.status_code in {302, 307}
|
| 49 |
+
assert response.headers.get("location") == "/"
|
| 50 |
|
| 51 |
|
| 52 |
def test_healthz_endpoint_returns_versioned_ok():
|