-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbu
More file actions
35 lines (26 loc) · 769 Bytes
/
Copy pathbu
File metadata and controls
35 lines (26 loc) · 769 Bytes
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
from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from database.database import engine
from database.seed import seed
from model.models import Base
from web import accommodation_router, reservation_router
Base.metadata.create_all(bind=engine)
@asynccontextmanager
async def lifespan(app: FastAPI):
seed()
yield
app = FastAPI(lifespan=lifespan)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(accommodation_router.router)
app.include_router(reservation_router.router)
# Test routes (optional)
@app.get("/")
async def root():
return {"message": "API is running"}