-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.py
More file actions
27 lines (22 loc) · 848 Bytes
/
api.py
File metadata and controls
27 lines (22 loc) · 848 Bytes
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
# api.py
from fastapi import FastAPI, HTTPException
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel
from graph.review_graph import run_review
app = FastAPI(title="AI Code Review API", version="1.0.0")
app.add_middleware(CORSMiddleware, allow_origins=["*"],
allow_methods=["*"], allow_headers=["*"])
class ReviewRequest(BaseModel):
pr_url: str
@app.get("/")
def root():
return {"status": "Code Review API running", "endpoint": "POST /review"}
@app.post("/review")
def review(request: ReviewRequest):
try:
report = run_review(request.pr_url)
return {"report": report, "status": "success"}
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))