AE-Shree commited on
Commit Β·
67460a4
1
Parent(s): 7c3efb7
Deploy BioStack RLHF Medical Demo
Browse files
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)
|