33 lines
942 B
Python
33 lines
942 B
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from pydantic import BaseModel
|
|
|
|
app = FastAPI()
|
|
|
|
# Enable CORS for NestJS (or directly for React if you prefer)
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"], # In production, restrict this to your NestJS server domain
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Hardcoded Leads Data
|
|
LEADS = [
|
|
{"id": 1, "name": "Alex Rivera", "email": "alex@company.com"},
|
|
{"id": 2, "name": "Jordan Smith", "email": "jsmith@leads.io"},
|
|
]
|
|
|
|
@app.get("/leads")
|
|
def get_leads():
|
|
return {"leads": LEADS}
|
|
|
|
class FeedbackData(BaseModel):
|
|
status: str
|
|
reason: str
|
|
|
|
@app.post("/leads/{lead_id}/feedback")
|
|
def receive_feedback(lead_id: str, feedback: FeedbackData):
|
|
# Now FastAPI knows exactly what structure to look for
|
|
print(f"Received feedback for {lead_id}: {feedback.status}, {feedback.reason}")
|
|
return {"status": "success"} |