from fastapi import FastAPI from app.api import chat from fastapi.middleware.cors import CORSMiddleware from app.schema.question import Question as SchemaQuestion import os from dotenv import load_dotenv load_dotenv() origins = [ "http://localhost:3000", "http://localhost:4000", ] app = FastAPI() app.include_router(chat.router, prefix="/api/chat", tags=["chat"]) app.add_middleware( CORSMiddleware, allow_origins=origins, allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) @app.get("/") async def read_root(): return {"message": "Welcome to the API"} @app.post("/") async def home(question: SchemaQuestion): return await chat.home(question)