AE-Shree commited on
Commit
67460a4
Β·
1 Parent(s): 7c3efb7

Deploy BioStack RLHF Medical Demo

Browse files
Files changed (1) hide show
  1. server.py +15 -11
server.py CHANGED
@@ -373,19 +373,9 @@ def reward_feedback(report: str, score: float) -> str:
373
  # ─────────────────────────────────────────────────────────────────────────────
374
  app = FastAPI(title="RLHF Medical Demo")
375
 
376
- # Mount static files for React app (must come before CORS and routes)
377
- from fastapi.staticfiles import StaticFiles
378
- import os
379
-
380
- # Check if build directory exists, create fallback if needed
381
- if os.path.exists("build"):
382
- app.mount("/", StaticFiles(directory="build", html=True), name="static")
383
- else:
384
- print("WARNING: Build directory not found, serving API only")
385
-
386
  app.add_middleware(
387
  CORSMiddleware,
388
- allow_origins=["*"],
389
  allow_methods=["*"],
390
  allow_headers=["*"],
391
  )
@@ -501,6 +491,20 @@ def debug_keys():
501
  return result
502
 
503
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
504
  if __name__ == "__main__":
505
  import uvicorn
506
  uvicorn.run(app, host="0.0.0.0", port=7860, reload=False)
 
373
  # ─────────────────────────────────────────────────────────────────────────────
374
  app = FastAPI(title="RLHF Medical Demo")
375
 
 
 
 
 
 
 
 
 
 
 
376
  app.add_middleware(
377
  CORSMiddleware,
378
+ allow_origins=["*"], # Allow all origins for Hugging Face Spaces
379
  allow_methods=["*"],
380
  allow_headers=["*"],
381
  )
 
491
  return result
492
 
493
 
494
+ # ─────────────────────────────────────────────────────────────────────────────
495
+ # STATIC FILE SERVING - Mount React build directory AFTER all API routes
496
+ # ─────────────────────────────────────────────────────────────────────────────
497
+ from fastapi.staticfiles import StaticFiles
498
+ import os
499
+
500
+ # Check if build directory exists, create fallback if needed
501
+ if os.path.exists("build"):
502
+ app.mount("/", StaticFiles(directory="build", html=True), name="static")
503
+ print("βœ… React app mounted at /")
504
+ else:
505
+ print("⚠️ Build directory not found, serving API only")
506
+
507
+
508
  if __name__ == "__main__":
509
  import uvicorn
510
  uvicorn.run(app, host="0.0.0.0", port=7860, reload=False)