File size: 818 Bytes
57d31f8 |
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 |
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from core.database import engine
from core.models.appointment import Appointment
from core.models.user import User
from routes import appointments, users
# Create FastAPI app first
app = FastAPI()
@app.get("/")
def health_check():
return {"message": "π API is up and running!"}
# β
Enable CORS BEFORE including any routers
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:3000"], # React frontend
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Create tables
Appointment.__table__.create(bind=engine, checkfirst=True)
User.__table__.create(bind=engine, checkfirst=True)
# Register routers
app.include_router(appointments.router)
app.include_router(users.router)
|