|
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): |
|
|
|
deploy_id = str(uuid.uuid4()) |
|
deployments[deploy_id] = { |
|
"github_url": req.github_url, |
|
"user_id": req.user_id, |
|
"status": "deploying", |
|
"url": None |
|
} |
|
|
|
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"} |