| from fastapi import FastAPI |
| import uvicorn |
| from models.models import Action |
| from env.priority_panic_env import MetaLearningPriorityPanicEnv |
|
|
| app = FastAPI() |
| env_instance = None |
|
|
| @app.post("/reset") |
| async def reset(): |
| global env_instance |
| env_instance = MetaLearningPriorityPanicEnv(task_id="easy") |
| return env_instance.reset() |
|
|
| @app.post("/step") |
| async def step(action: dict): |
| global env_instance |
| action_obj = Action(**action) |
| return env_instance.step(action_obj) |
|
|
| @app.get("/") |
| def root(): |
| return {"status": "running"} |
|
|
| def main(): |
| uvicorn.run(app, host="0.0.0.0", port=7860) |
|
|
| if __name__ == "__main__": |
| main() |