Update proxy_server.py
Browse files- proxy_server.py +14 -1
proxy_server.py
CHANGED
|
@@ -1,4 +1,6 @@
|
|
| 1 |
from fastapi import FastAPI, HTTPException
|
|
|
|
|
|
|
| 2 |
import httpx
|
| 3 |
import os
|
| 4 |
from pydantic import BaseModel
|
|
@@ -66,5 +68,16 @@ async def proxy_to_lambda(earthquake_request: EarthquakeRequest):
|
|
| 66 |
async def health_check():
|
| 67 |
return {"status": "healthy", "service": "earthquake-proxy"}
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
if __name__ == "__main__":
|
| 70 |
-
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
|
| 1 |
from fastapi import FastAPI, HTTPException
|
| 2 |
+
from fastapi.staticfiles import StaticFiles # ADD THIS
|
| 3 |
+
from fastapi.responses import FileResponse # ADD THIS
|
| 4 |
import httpx
|
| 5 |
import os
|
| 6 |
from pydantic import BaseModel
|
|
|
|
| 68 |
async def health_check():
|
| 69 |
return {"status": "healthy", "service": "earthquake-proxy"}
|
| 70 |
|
| 71 |
+
# Mount static files from dist directory
|
| 72 |
+
if os.path.exists("dist/assets"):
|
| 73 |
+
app.mount("/assets", StaticFiles(directory="dist/assets"), name="assets")
|
| 74 |
+
|
| 75 |
+
# Serve React app for all non-API routes
|
| 76 |
+
@app.get("/{full_path:path}")
|
| 77 |
+
async def serve_react_app(full_path: str = ""):
|
| 78 |
+
if full_path.startswith("api/"):
|
| 79 |
+
raise HTTPException(status_code=404, detail="API endpoint not found")
|
| 80 |
+
return FileResponse("dist/index.html")
|
| 81 |
+
|
| 82 |
if __name__ == "__main__":
|
| 83 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|