INNER CODE UNIT · Python

spa_fallback

gokulapap/Reconator · backend/app/main.py:94

    async def spa_fallback(request: Request, exc: StarletteHTTPException):
        if (
            exc.status_code == 404
            and request.method == "GET"
            and not request.url.path.startswith(("/api", "/docs", "/openapi", "/redoc"))
        ):
            return FileResponse(_index_file)
        return JSONResponse({"detail": exc.detail}, status_code=exc.status_code)
else:

    @app.get("/", include_in_schema=False)
    def root() -> dict[str, str]:
        return {
            "name": settings.app_name,
            "version": settings.app_version,
            "docs": "/docs",
            "api": settings.api_prefix,
        }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…