ciyidogan commited on
Commit
a50f65d
Β·
verified Β·
1 Parent(s): dcf647a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -31,7 +31,18 @@ def health_check():
31
 
32
  # ---------------- Serve Angular UI if exists ------------------------
33
  static_path = Path("static")
 
 
 
34
  if static_path.exists() and static_path.is_dir():
 
 
 
 
 
 
 
 
35
  # Serve static files (Angular assets) - only if assets directory exists
36
  assets_path = static_path / "assets"
37
  if assets_path.exists() and assets_path.is_dir():
@@ -42,8 +53,10 @@ if static_path.exists() and static_path.is_dir():
42
  async def serve_root():
43
  index_path = static_path / "index.html"
44
  if index_path.exists():
 
45
  return FileResponse(str(index_path))
46
- return {"status": "ok"} # Fallback to health check
 
47
 
48
  # Catch-all route for Angular routing (must be last!)
49
  @app.get("/{full_path:path}")
@@ -58,10 +71,11 @@ if static_path.exists() and static_path.is_dir():
58
  return FileResponse(str(index_path))
59
  return {"error": "UI not found"}, 404
60
  else:
 
61
  # No UI built, just health endpoint
62
  @app.get("/")
63
  def health_check():
64
- return {"status": "ok", "message": "UI not found. Build Angular app first."}
65
 
66
  if __name__ == "__main__":
67
  log("🌐 Starting Flare backend …")
 
31
 
32
  # ---------------- Serve Angular UI if exists ------------------------
33
  static_path = Path("static")
34
+ log(f"πŸ” Checking for static directory at: {static_path.absolute()}")
35
+ log(f"πŸ” Static directory exists: {static_path.exists()}")
36
+
37
  if static_path.exists() and static_path.is_dir():
38
+ # List files in static directory
39
+ files = list(static_path.iterdir())
40
+ log(f"πŸ“ Files in static directory: {[f.name for f in files]}")
41
+
42
+ # Check for index.html
43
+ index_path = static_path / "index.html"
44
+ log(f"πŸ” index.html exists: {index_path.exists()}")
45
+
46
  # Serve static files (Angular assets) - only if assets directory exists
47
  assets_path = static_path / "assets"
48
  if assets_path.exists() and assets_path.is_dir():
 
53
  async def serve_root():
54
  index_path = static_path / "index.html"
55
  if index_path.exists():
56
+ log("πŸ“„ Serving index.html")
57
  return FileResponse(str(index_path))
58
+ log("⚠️ index.html not found, returning health check")
59
+ return {"status": "ok", "sessions": len(session_store._sessions)} # Fallback to health check
60
 
61
  # Catch-all route for Angular routing (must be last!)
62
  @app.get("/{full_path:path}")
 
71
  return FileResponse(str(index_path))
72
  return {"error": "UI not found"}, 404
73
  else:
74
+ log("⚠️ Static directory not found")
75
  # No UI built, just health endpoint
76
  @app.get("/")
77
  def health_check():
78
+ return {"status": "ok", "message": "UI not found. Build Angular app first."}I not found. Build Angular app first."}
79
 
80
  if __name__ == "__main__":
81
  log("🌐 Starting Flare backend …")