MCPcopy Create free account
hub / github.com/Datakitpage/Datakit / catch_all

Function catch_all

cli-python/datakit_local/server.py:82–96  ·  view source on GitHub ↗

Handle client-side routing by serving index.html for all routes

(request: Request, full_path: str)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected