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