Hariprasath5128 commited on
Commit
2e66064
·
1 Parent(s): 8a5fc23

Add HF healthcheck routes

Browse files
Files changed (1) hide show
  1. server.py +19 -1
server.py CHANGED
@@ -302,10 +302,28 @@ Higher scores = better efficiency. Be precise with your /10 ratings."""
302
 
303
 
304
  if FRONTEND_BUILD_DIR.exists():
305
- app.mount("/assets", StaticFiles(directory=FRONTEND_BUILD_DIR / "static"), name="static")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
306
 
307
 
308
  @app.get("/{full_path:path}")
 
309
  async def serve_frontend(full_path: str):
310
  if not FRONTEND_BUILD_DIR.exists():
311
  raise HTTPException(
 
302
 
303
 
304
  if FRONTEND_BUILD_DIR.exists():
305
+ app.mount("/static", StaticFiles(directory=FRONTEND_BUILD_DIR / "static"), name="static")
306
+
307
+
308
+ @app.get("/healthz")
309
+ @app.head("/healthz")
310
+ async def healthcheck():
311
+ return {"status": "ok"}
312
+
313
+
314
+ @app.get("/")
315
+ @app.head("/")
316
+ async def serve_index():
317
+ if not FRONTEND_BUILD_DIR.exists():
318
+ raise HTTPException(
319
+ status_code=404,
320
+ detail="Frontend build not found. Run the React build or deploy with the Dockerfile.",
321
+ )
322
+ return FileResponse(FRONTEND_BUILD_DIR / "index.html")
323
 
324
 
325
  @app.get("/{full_path:path}")
326
+ @app.head("/{full_path:path}")
327
  async def serve_frontend(full_path: str):
328
  if not FRONTEND_BUILD_DIR.exists():
329
  raise HTTPException(