INNER CODE UNIT · Python
_spa_fallback
ohdearquant/lionagi · lionagi/studio/app.py:337
async def _spa_fallback(request: Request, exc: Exception) -> FileResponse | JSONResponse:
# /api/* paths stay 404 JSON here, not the SPA HTML shell.
path = request.url.path
if path.startswith("/api/") or path == "/api":
return JSONResponse({"detail": "Not Found"}, status_code=404)
if request.method not in ("GET", "HEAD"):
return JSONResponse({"detail": "Not Found"}, status_code=404)
return FileResponse(
str(index_path),
headers={
"Cache-Control": "no-store, no-cache, must-revalidate",
"Pragma": "no-cache",
},
)
def create_app() -> FastAPI:
"""Build and return a fresh Studio FastAPI app instance, so callers