oversightforge-2 / server.py
testtest123's picture
fix ui
037b5fc
Raw History Blame Contribute Delete
1.08 kB
"""
Combined server for HuggingFace Spaces deployment.
Serves both the OversightForge environment API (for training) and the
dashboard UI (for live demo) on a single port (7860).
Environment API endpoints: /reset, /step, /state, /health, /reset_eval
Dashboard endpoints: /dashboard, /dashboard/events, /dashboard/state
Dashboard UI: / (root shows the dashboard)
"""
import sys
import os
# Add the app directory to the path so imports work
sys.path.insert(0, "/app/environment")
sys.path.insert(0, "/app/dashboard")
from fastapi import FastAPI
from fastapi.responses import HTMLResponse
# Import both apps
from environment.app.main import app as env_app
from dashboard.app.main import app as dash_app, index as dashboard_index
# Use the environment app as the base so all its routes work natively
app = env_app
app.title = "OversightForge 2.0"
app.version = "2.0.0"
# Mount the dashboard at /dashboard
app.mount("/dashboard", dash_app)
@app.get("/", response_class=HTMLResponse)
def root():
"""Root page — show the dashboard directly."""
return dashboard_index()