Download server/app.py from xdAILabs/edge-deployment-resource-optimization: direct link, hf CLI and curl.
- Browser
- Download file 951 Bytes
-
https://huggingface.co/spaces/xdAILabs/edge-deployment-resource-optimization/resolve/main/server/app.py
- Command line
-
hf download hf://spaces/xdAILabs/edge-deployment-resource-optimization/server/app.py
-
curl -L -o app.py https://huggingface.co/spaces/xdAILabs/edge-deployment-resource-optimization/resolve/main/server/app.py
951 Bytes
| from fastapi import FastAPI | |
| import uvicorn | |
| import os | |
| app = FastAPI() | |
| async def root(): | |
| return { | |
| "message": "Edge Deployment Environment is Live", | |
| "status": "Ready for OpenEnv Evaluation", | |
| "endpoints": ["/reset", "/step", "/state"] | |
| } | |
| async def reset(): | |
| # Your reset logic here | |
| return {"status": "success"} | |
| async def step(action: dict): | |
| # Your step logic here | |
| return {"observation": {}, "reward": 0.0, "done": False} | |
| def main(): | |
| """ | |
| Main entry point for the environment server. | |
| Required by OpenEnv Spec and Hugging Face runtime. | |
| """ | |
| # Hugging Face defaults to 7860, but OpenEnv may pass a PORT env var | |
| port = int(os.environ.get("PORT", 7860)) | |
| # Hugging Face Spaces REQUIRES port 7860 | |
| print(f"Starting server on port {port}...") | |
| uvicorn.run(app, host="0.0.0.0", port=7860) | |
| if __name__ == "__main__": | |
| main() |