Spaces:
Runtime error
Runtime error
DEBUG: CORS
Browse files
main.py
CHANGED
|
@@ -3,22 +3,31 @@ from fastapi.exceptions import HTTPException
|
|
| 3 |
from fastapi.responses import JSONResponse
|
| 4 |
from api.services import FastAPIService
|
| 5 |
from fastapi import FastAPI
|
|
|
|
| 6 |
|
| 7 |
service = FastAPIService()
|
| 8 |
-
app = FastAPI(title
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
@app.post("/answerQuery")
|
| 11 |
async def answerQuery(queryModel: WorkflowQuery):
|
| 12 |
try:
|
| 13 |
-
response = service.answerQuery(workflowQueryModel
|
| 14 |
-
return JSONResponse(status_code
|
| 15 |
except Exception as e:
|
| 16 |
-
raise HTTPException(status_code
|
| 17 |
|
| 18 |
@app.post("/flag")
|
| 19 |
async def flagOutput(flagModel: FlagOutput):
|
| 20 |
try:
|
| 21 |
-
response = service.flagResponse(likedOrFlaggedModel
|
| 22 |
-
return JSONResponse(status_code
|
| 23 |
except Exception as e:
|
| 24 |
-
raise HTTPException(status_code
|
|
|
|
| 3 |
from fastapi.responses import JSONResponse
|
| 4 |
from api.services import FastAPIService
|
| 5 |
from fastapi import FastAPI
|
| 6 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 7 |
|
| 8 |
service = FastAPIService()
|
| 9 |
+
app = FastAPI(title="Agentic Data Pipeline Endpoints")
|
| 10 |
+
|
| 11 |
+
app.add_middleware(
|
| 12 |
+
CORSMiddleware,
|
| 13 |
+
allow_origins=["*"],
|
| 14 |
+
allow_credentials=True,
|
| 15 |
+
allow_methods=["*"],
|
| 16 |
+
allow_headers=["*"],
|
| 17 |
+
)
|
| 18 |
|
| 19 |
@app.post("/answerQuery")
|
| 20 |
async def answerQuery(queryModel: WorkflowQuery):
|
| 21 |
try:
|
| 22 |
+
response = service.answerQuery(workflowQueryModel=queryModel)
|
| 23 |
+
return JSONResponse(status_code=200, content={"response": response})
|
| 24 |
except Exception as e:
|
| 25 |
+
raise HTTPException(status_code=500, detail=str(e))
|
| 26 |
|
| 27 |
@app.post("/flag")
|
| 28 |
async def flagOutput(flagModel: FlagOutput):
|
| 29 |
try:
|
| 30 |
+
response = service.flagResponse(likedOrFlaggedModel=flagModel)
|
| 31 |
+
return JSONResponse(status_code=200, content={"response": response})
|
| 32 |
except Exception as e:
|
| 33 |
+
raise HTTPException(status_code=500, detail=str(e))
|