thepikachu's picture
moved app.py to fix the runtime error
157160f
Raw
History Blame Contribute Delete
1.51 kB
# app.py
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
try:
from openenv.core.env_server.http_server import create_app
except Exception as e: # pragma: no cover
raise ImportError(
"openenv is required for the web interface. Install dependencies with '\n uv sync\n'"
) from e
from fastapi.responses import RedirectResponse, JSONResponse
try:
from ..models import ArchitectureAction, ArchitectureObservation
from .architecture_env_environment import ArchitectureEnvironment
except ImportError:
from models import ArchitectureAction, ArchitectureObservation
from server.architecture_env_environment import ArchitectureEnvironment
app = create_app(
ArchitectureEnvironment,
ArchitectureAction,
ArchitectureObservation,
env_name="architecture_env",
max_concurrent_envs=1,
)
@app.get("/", include_in_schema=False)
async def root():
return JSONResponse({"status": "ok", "app": "architecture_env"})
@app.get("/web", include_in_schema=False)
@app.get("/web/", include_in_schema=False)
@app.get("/web/{path:path}", include_in_schema=False)
async def web_alias(path: str = ""):
target = "/" if not path else f"/{path}"
return RedirectResponse(url=target)
def main():
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
if __name__ == "__main__":
main()