15 lines
399 B
Python
15 lines
399 B
Python
from contextlib import asynccontextmanager
|
|
from fastapi import FastAPI
|
|
from app.database import engine
|
|
from app.routers import authors, books
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
yield # tables already created by Create.sql
|
|
await engine.dispose()
|
|
|
|
app = FastAPI(title="Database API", lifespan=lifespan)
|
|
|
|
app.include_router(authors.router)
|
|
app.include_router(books.router)
|