File size: 880 Bytes
5825f9f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
from fastapi import FastAPI, Request
from pydantic import BaseModel
import uuid
app = FastAPI()
deployments = {}
class DeployRequest(BaseModel):
github_url: str
user_id: str
@app.post("/deploy")
async def deploy(req: DeployRequest):
# Simulate deployment
deploy_id = str(uuid.uuid4())
deployments[deploy_id] = {
"github_url": req.github_url,
"user_id": req.user_id,
"status": "deploying",
"url": None
}
# Simulate deployment done after a few seconds (in real app, use background task)
deployments[deploy_id]["status"] = "success"
deployments[deploy_id]["url"] = f"https://demo-deployment/{deploy_id}"
return {"deploy_id": deploy_id}
@app.get("/status/{deploy_id}")
async def status(deploy_id: str):
if deploy_id in deployments:
return deployments[deploy_id]
return {"error": "Not found"} |