22 lines
477 B
Python
22 lines
477 B
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from .routers import example_router
|
|
|
|
app = FastAPI()
|
|
|
|
# Configure CORS
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["http://localhost:5173"], # Vite's default port
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Include routers
|
|
app.include_router(example_router.router)
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {"message": "Welcome to FastAPI"}
|