Download Backend/api/server.py from Mey-agen/MVP: direct link, hf CLI and curl.
- Browser
- Download file 703 Bytes
-
https://huggingface.co/spaces/Mey-agen/MVP/resolve/main/Backend/api/server.py
- Command line
-
hf download hf://spaces/Mey-agen/MVP/Backend/api/server.py
-
curl -L -o server.py https://huggingface.co/spaces/Mey-agen/MVP/resolve/main/Backend/api/server.py
703 Bytes
| import sys | |
| from pathlib import Path | |
| # Ensure Backend directory is in sys.path and load root .env | |
| BACKEND_DIR = Path(__file__).resolve().parent.parent | |
| if str(BACKEND_DIR) not in sys.path: | |
| sys.path.insert(0, str(BACKEND_DIR)) | |
| import config | |
| from fastapi import FastAPI, HTTPException | |
| from schemas.agent_spec import AgentSpec | |
| from executor.executor import execute_spec | |
| app = FastAPI(title="Agent Execution API") | |
| def execute(spec: AgentSpec): | |
| try: | |
| result = execute_spec(spec) | |
| return {"result": result} | |
| except Exception as e: | |
| raise HTTPException( | |
| status_code=500, | |
| detail=f"Error executing agent spec: {str(e)}" | |
| ) | |