triage-flow / server /app.py
StrongCapybara's picture
feat(ui): implement modern clinical dashboard interface using custom gradio blocks
f503df8
Raw
History Blame Contribute Delete
1.91 kB
"""
Module: app.py
Purpose: FastAPI server exposing the TriageFlow environment via HTTP/WebSocket.
Part of: Medical Triage Assistant — OpenEnv Round 1
Author: Team Squirrel
Overview:
Uses OpenEnv's create_app() to automatically create all required
endpoints: /reset, /step, /state, /health, /ws, /docs, /web.
This is the entry point when running the server in Docker or locally.
Dependencies:
- openenv.core.env_server.http_server: create_app
- models: TriageAction, TriageObservation
- server.triage_flow_environment: TriageEnvironment
Usage:
uvicorn server.app:app --host 0.0.0.0 --port 8000
"""
try:
from openenv.core.env_server.http_server import create_app
except ImportError:
from openenv.core.env_server import create_fastapi_app as create_app
try:
from ..models import TriageAction, TriageObservation
from .triage_flow_environment import TriageEnvironment
except (ImportError, ModuleNotFoundError):
import sys, os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from models import TriageAction, TriageObservation
from server.triage_flow_environment import TriageEnvironment
from .ui import build_triage_ui
# Create the app with web interface
app = create_app(
TriageEnvironment,
TriageAction,
TriageObservation,
env_name="triage_flow",
max_concurrent_envs=1,
gradio_builder=build_triage_ui
)
from fastapi.responses import RedirectResponse
@app.get("/")
def redirect_to_web():
return RedirectResponse(url="/web")
def main(host: str = "0.0.0.0", port: int = 8000):
"""
Entry point for direct execution via uv run or python -m.
Args:
host: Host address to bind to (default: "0.0.0.0")
port: Port number to listen on (default: 8000)
"""
import uvicorn
uvicorn.run(app, host=host, port=port)
if __name__ == "__main__":
main()