Spaces:
Build error
Build error
Update Dockerfile
Browse files- Dockerfile +32 -1
Dockerfile
CHANGED
|
@@ -49,6 +49,37 @@ for root, dirs, files in os.walk("frontend"):\n\
|
|
| 49 |
for file in files:\n\
|
| 50 |
logger.info(f" {os.path.join(root, file)}")\n\
|
| 51 |
\n\
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
# Custom static file handler to ensure proper content types\n\
|
| 53 |
@app.get("/static/{file_path:path}")\n\
|
| 54 |
async def get_static(file_path: str):\n\
|
|
@@ -80,7 +111,7 @@ async def get_static(file_path: str):\n\
|
|
| 80 |
\n\
|
| 81 |
return FileResponse(full_path, media_type=content_type)\n\
|
| 82 |
\n\
|
| 83 |
-
# Serve specific CSS files directly\n\
|
| 84 |
@app.get("/landing.css")\n\
|
| 85 |
async def get_landing_css():\n\
|
| 86 |
return FileResponse("frontend/landing.css", media_type="text/css")\n\
|
|
|
|
| 49 |
for file in files:\n\
|
| 50 |
logger.info(f" {os.path.join(root, file)}")\n\
|
| 51 |
\n\
|
| 52 |
+
# Handle the specific /frontend/ prefix issue\n\
|
| 53 |
+
@app.get("/frontend/{file_path:path}")\n\
|
| 54 |
+
async def get_frontend_file(file_path: str):\n\
|
| 55 |
+
full_path = f"frontend/{file_path}"\n\
|
| 56 |
+
if not os.path.exists(full_path):\n\
|
| 57 |
+
logger.warning(f"Frontend file not found: {full_path}")\n\
|
| 58 |
+
return Response(status_code=404)\n\
|
| 59 |
+
\n\
|
| 60 |
+
logger.info(f"Serving frontend file: {full_path}")\n\
|
| 61 |
+
\n\
|
| 62 |
+
# Set content type based on file extension\n\
|
| 63 |
+
ext = os.path.splitext(file_path)[1].lower()\n\
|
| 64 |
+
content_type = "application/octet-stream" # default\n\
|
| 65 |
+
\n\
|
| 66 |
+
if ext == ".css":\n\
|
| 67 |
+
content_type = "text/css"\n\
|
| 68 |
+
elif ext in [".js", ".mjs"]:\n\
|
| 69 |
+
content_type = "application/javascript"\n\
|
| 70 |
+
elif ext == ".html":\n\
|
| 71 |
+
content_type = "text/html"\n\
|
| 72 |
+
elif ext in [".jpg", ".jpeg"]:\n\
|
| 73 |
+
content_type = "image/jpeg"\n\
|
| 74 |
+
elif ext == ".png":\n\
|
| 75 |
+
content_type = "image/png"\n\
|
| 76 |
+
elif ext == ".svg":\n\
|
| 77 |
+
content_type = "image/svg+xml"\n\
|
| 78 |
+
elif ext == ".json":\n\
|
| 79 |
+
content_type = "application/json"\n\
|
| 80 |
+
\n\
|
| 81 |
+
return FileResponse(full_path, media_type=content_type)\n\
|
| 82 |
+
\n\
|
| 83 |
# Custom static file handler to ensure proper content types\n\
|
| 84 |
@app.get("/static/{file_path:path}")\n\
|
| 85 |
async def get_static(file_path: str):\n\
|
|
|
|
| 111 |
\n\
|
| 112 |
return FileResponse(full_path, media_type=content_type)\n\
|
| 113 |
\n\
|
| 114 |
+
# Serve specific CSS files directly as well\n\
|
| 115 |
@app.get("/landing.css")\n\
|
| 116 |
async def get_landing_css():\n\
|
| 117 |
return FileResponse("frontend/landing.css", media_type="text/css")\n\
|