INNER CODE UNIT · Python
serve_frontend
GuntharDeNiro/gunbot-quant · gunbot_quant/api/main.py:70
async def serve_frontend(request: Request, full_path: str):
"""
Catch-all endpoint to serve the frontend's index.html.
This is necessary for client-side routing to work correctly.
"""
# Path to the main index.html file
index_path = os.path.join(frontend_dir, 'index.html')
# Check for static files like favicon.ico or vite.svg
potential_file_path = os.path.join(frontend_dir, full_path)
if os.path.isfile(potential_file_path):
return FileResponse(potential_file_path)
# For any other path, serve the main index.html
return FileResponse(index_path)
else:
# Fallback message if the frontend hasn't been built