Spaces:
Sleeping
Sleeping
File size: 1,192 Bytes
e0a73da a0df48e 057d3c8 fa99d8f 057d3c8 e0a73da fa99d8f e0a73da fa99d8f e0a73da fa99d8f e0a73da 057d3c8 e0a73da |
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 28 29 30 31 32 33 34 35 36 37 38 39 |
from fastapi import FastAPI
from app.api.v1.api import api_router as api_router_v1
from fastapi.responses import HTMLResponse
from app.core.config import settings
from app.templates.chat import chat_html
#from app.core.config import settings
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI(
title=settings.PROJECT_NAME,
version=settings.API_VERSION,
openapi_url=f"{settings.API_V1_STR}/openapi.json",
)
#BACKEND_CORS_ORIGINS = ["*"]
# CORS Middleware setup for allowing frontend requests
# ToDO: replace with settings.BACKEND_CORS_ORIGINS once core/config.py is implemented
if settings.BACKEND_CORS_ORIGINS:
app.add_middleware(
CORSMiddleware,
allow_origins=[str(origin) for origin in settings.BACKEND_CORS_ORIGINS],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/", tags=["Root"])
async def root():
"""
Simple root endpoint to verify the API is running.
"""
return {"message": "API is running"}
@app.get("/chat", response_class=HTMLResponse)
async def chat():
return chat_html
# Include the versioned API router from api.py
app.include_router(api_router_v1) |