Redirect / to /ui (handles bare Space URL + HF healthcheck)
Browse files- api/main.py +7 -1
api/main.py
CHANGED
|
@@ -31,7 +31,7 @@ from dotenv import load_dotenv
|
|
| 31 |
from fastapi import Depends, FastAPI, Form, HTTPException, Request, status
|
| 32 |
from fastapi.exceptions import RequestValidationError
|
| 33 |
from fastapi.middleware.cors import CORSMiddleware
|
| 34 |
-
from fastapi.responses import HTMLResponse, JSONResponse
|
| 35 |
from fastapi.security import HTTPBasic, HTTPBasicCredentials
|
| 36 |
from fastapi.staticfiles import StaticFiles
|
| 37 |
from fastapi.templating import Jinja2Templates
|
|
@@ -140,6 +140,12 @@ async def _validation_handler(request: Request, exc: RequestValidationError) ->
|
|
| 140 |
return JSONResponse(status_code=400, content={"error": "invalid_request"})
|
| 141 |
|
| 142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
@app.get("/health")
|
| 144 |
def health() -> JSONResponse:
|
| 145 |
"""Liveness + DB reachability. No internals leaked on failure."""
|
|
|
|
| 31 |
from fastapi import Depends, FastAPI, Form, HTTPException, Request, status
|
| 32 |
from fastapi.exceptions import RequestValidationError
|
| 33 |
from fastapi.middleware.cors import CORSMiddleware
|
| 34 |
+
from fastapi.responses import HTMLResponse, JSONResponse, RedirectResponse
|
| 35 |
from fastapi.security import HTTPBasic, HTTPBasicCredentials
|
| 36 |
from fastapi.staticfiles import StaticFiles
|
| 37 |
from fastapi.templating import Jinja2Templates
|
|
|
|
| 140 |
return JSONResponse(status_code=400, content={"error": "invalid_request"})
|
| 141 |
|
| 142 |
|
| 143 |
+
@app.get("/", include_in_schema=False)
|
| 144 |
+
def root() -> RedirectResponse:
|
| 145 |
+
"""Bare Space URL → /ui. Also catches HF Spaces' platform healthcheck."""
|
| 146 |
+
return RedirectResponse(url="/ui", status_code=307)
|
| 147 |
+
|
| 148 |
+
|
| 149 |
@app.get("/health")
|
| 150 |
def health() -> JSONResponse:
|
| 151 |
"""Liveness + DB reachability. No internals leaked on failure."""
|