Spaces:
Running
Running
from fastapi import FastAPI, Response | |
from app.api.v1.api import api_router | |
from fastapi.middleware.cors import CORSMiddleware | |
from app.models.schemas import StandardResponse | |
app = FastAPI(title="Cognisafe API") | |
origins = [ | |
"https://cognisafe.netlify.app", # Your frontend origin | |
"https://zyriean-cognisafe-backend.hf.space", # <-- **THIS IS CRUCIAL** | |
# You might also want to include localhost for local development: | |
"http://localhost", | |
"http://localhost:8000", # Or whatever port you use for local testing | |
] | |
app.add_middleware( | |
CORSMiddleware, | |
allow_origins=origins, # or ["*"] for all origins (not recommended in prod) | |
allow_credentials=True, | |
allow_methods=["*"], | |
allow_headers=["*"], | |
) | |
async def health_check(): | |
return {"status": "healthy"} | |
def helloworld(response: Response) -> StandardResponse: | |
""" | |
Returns helloworld as the standard response | |
""" | |
response.status_code = 200 | |
response = StandardResponse(error=False, title="Hello World", status=200) | |
return response | |
app.include_router(api_router, prefix="/api/v1") |