Handle client-side routing by serving index.html for all routes
(request: Request, full_path: str)
| 80 | |
| 81 | @app.get("/{full_path:path}") |
| 82 | async def catch_all(request: Request, full_path: str): |
| 83 | """Handle client-side routing by serving index.html for all routes""" |
| 84 | # Check if it's a request for a static file |
| 85 | file_path = static_path / full_path |
| 86 | |
| 87 | # If file exists, serve it |
| 88 | if file_path.is_file(): |
| 89 | return FileResponse(file_path) |
| 90 | |
| 91 | # For everything else (SPA routes), serve index.html |
| 92 | index_file = static_path / "index.html" |
| 93 | if index_file.exists(): |
| 94 | return FileResponse(index_file) |
| 95 | else: |
| 96 | return {"error": "DataKit static files not found"} |
| 97 | |
| 98 | return app |
| 99 |
nothing calls this directly
no outgoing calls
no test coverage detected