Spaces:
Running
Running
Download server/app.py from aakarsh2007/Oceanus-AI: direct link, hf CLI and curl.
- Browser
- Download file 1.02 kB
-
https://huggingface.co/spaces/aakarsh2007/Oceanus-AI/resolve/main/server/app.py
- Command line
-
hf download hf://spaces/aakarsh2007/Oceanus-AI/server/app.py
-
curl -L -o app.py https://huggingface.co/spaces/aakarsh2007/Oceanus-AI/resolve/main/server/app.py
1.02 kB
| """ | |
| Oceanus OpenEnv Server App | |
| Exposes the environment via REST API (OpenEnv-compatible). | |
| """ | |
| import sys | |
| import os | |
| sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from models import OceanusAction, OceanusObservation, OceanusState | |
| from server.oceanus_environment import OceanusEnvironment | |
| app = FastAPI(title="Oceanus OpenEnv Server", version="1.0.0") | |
| app.add_middleware(CORSMiddleware, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"]) | |
| env = OceanusEnvironment(seed=42, max_steps=120, chaos_interval=25) | |
| def reset(): | |
| return env.reset() | |
| def step(action: OceanusAction): | |
| return env.step(action) | |
| def state(): | |
| return env.state() | |
| def health(): | |
| return {"status": "ok", "environment": "Oceanus-v1"} | |