ciyidogan commited on
Commit
633b004
·
verified ·
1 Parent(s): 4dfdbc5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -114,18 +114,24 @@ if static_path.exists() and static_path.is_dir():
114
  return FileResponse(str(css_path), media_type="text/css")
115
  return {"error": "CSS file not found"}, 404
116
 
 
117
  # Catch-all route for Angular routing (must be last!)
118
  @app.get("/{full_path:path}")
119
  async def serve_angular(full_path: str):
120
  # Don't catch API routes
121
- if full_path.startswith("api/") or full_path in ["start_session", "chat", "health"]:
122
- return {"error": "Not found"}, 404
 
123
 
124
- # Return Angular index.html for all other routes
125
  index_path = static_path / "index.html"
126
  if index_path.exists():
 
127
  return FileResponse(str(index_path), media_type="text/html")
128
- return {"error": "UI not found"}, 404
 
 
 
129
  else:
130
  log("⚠️ Static directory not found")
131
  # No UI built, just health endpoint
 
114
  return FileResponse(str(css_path), media_type="text/css")
115
  return {"error": "CSS file not found"}, 404
116
 
117
+
118
  # Catch-all route for Angular routing (must be last!)
119
  @app.get("/{full_path:path}")
120
  async def serve_angular(full_path: str):
121
  # Don't catch API routes
122
+ if full_path.startswith("api/") or full_path.startswith("health"):
123
+ from fastapi import HTTPException
124
+ raise HTTPException(status_code=404, detail="Not found")
125
 
126
+ # For Angular routes, always return index.html
127
  index_path = static_path / "index.html"
128
  if index_path.exists():
129
+ log(f"🔀 Serving index.html for Angular route: /{full_path}")
130
  return FileResponse(str(index_path), media_type="text/html")
131
+
132
+ # If no index.html, return 404
133
+ from fastapi import HTTPException
134
+ raise HTTPException(status_code=404, detail="UI not found")
135
  else:
136
  log("⚠️ Static directory not found")
137
  # No UI built, just health endpoint