Commit ·
5718798
1
Parent(s): 92849be
fix: replace StaticFiles with FileResponse to bypass HF Space proxy 500 errors on static assets
Browse files- api/main.py +7 -1
api/main.py
CHANGED
|
@@ -330,7 +330,13 @@ elif os.path.isdir(_frontend_dist):
|
|
| 330 |
return HTMLResponse(content=html_content)
|
| 331 |
return {"detail": "Not Found"}
|
| 332 |
|
| 333 |
-
app.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 334 |
|
| 335 |
if __name__ == "__main__":
|
| 336 |
import uvicorn
|
|
|
|
| 330 |
return HTMLResponse(content=html_content)
|
| 331 |
return {"detail": "Not Found"}
|
| 332 |
|
| 333 |
+
@app.get("/{file_path:path}")
|
| 334 |
+
async def serve_static(file_path: str):
|
| 335 |
+
full_path = os.path.join(_frontend_dist, file_path)
|
| 336 |
+
if os.path.isfile(full_path):
|
| 337 |
+
from fastapi.responses import FileResponse
|
| 338 |
+
return FileResponse(full_path)
|
| 339 |
+
return {"detail": "Not Found"}
|
| 340 |
|
| 341 |
if __name__ == "__main__":
|
| 342 |
import uvicorn
|