| from __future__ import annotations | |
| from pathlib import Path | |
| from fastapi.responses import FileResponse | |
| from fastapi.staticfiles import StaticFiles | |
| from openenv.core.env_server.http_server import create_app | |
| from models import BDOAction, BDOObservation | |
| from server.bdo_environment import BDOEnvironment | |
| from server.game_api import router as ui_router | |
| app = create_app( | |
| BDOEnvironment, | |
| BDOAction, | |
| BDOObservation, | |
| env_name="bdo-ai", | |
| max_concurrent_envs=4, | |
| ) | |
| app.include_router(ui_router) | |
| UI_DIR = Path(__file__).resolve().parents[1] / "ui" | |
| app.mount("/ui-static", StaticFiles(directory=UI_DIR), name="ui-static") | |
| def ui_index() -> FileResponse: | |
| return FileResponse(UI_DIR / "index.html") | |
| def main(host: str = "0.0.0.0", port: int = 8000) -> None: | |
| import uvicorn | |
| uvicorn.run(app, host=host, port=port) | |
| if __name__ == "__main__": | |
| main() | |