host / app.py
dragxd's picture
Create app.py
5825f9f verified
raw
history blame
880 Bytes
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"}