REST API for managing personal bookmarks (title, link, category). PostgreSQL database with async SQLAlchemy, containerized with Docker Compose. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
20 lines
509 B
Python
20 lines
509 B
Python
from contextlib import asynccontextmanager
|
|
|
|
from fastapi import FastAPI
|
|
|
|
from app.database import engine
|
|
from app.models import Base
|
|
from app.routers import bookmarks, categorize, health
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
async with engine.begin() as conn:
|
|
await conn.run_sync(Base.metadata.create_all)
|
|
yield
|
|
|
|
|
|
app = FastAPI(title="Favs API", lifespan=lifespan)
|
|
app.include_router(health.router)
|
|
app.include_router(bookmarks.router)
|
|
app.include_router(categorize.router)
|