Spaces:
Running
Running
| import os | |
| import subprocess | |
| from fastapi import FastAPI, Query | |
| import uvicorn | |
| app = FastAPI() | |
| def index(): | |
| return {"status": "running", "msg": "Welcome to Agent-Reach Server"} | |
| # 给你留的远程后门:通过 URL 传参直接在容器里执行命令 | |
| def run_command(q: str = Query(..., description="The command to execute")): | |
| try: | |
| # 在容器中执行你的 agent-reach 命令 | |
| result = subprocess.check_output(q, shell=True, stderr=subprocess.STDOUT, text=True) | |
| return {"code": 0, "output": result} | |
| except subprocess.CalledProcessError as e: | |
| return {"code": 1, "output": e.output} | |
| if __name__ == "__main__": | |
| uvicorn.run(app, host="0.0.0.0", port=7860) |