Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /mdfarhankc_fastapi-fullauth /examples /tortoise_app /main.py
| """ | |
| Run: uv run uvicorn examples.tortoise_app.main:app --reload | |
| Requires: uv add fastapi-fullauth[tortoise] | |
| On Windows also install tzdata (Tortoise 1.x uses tz-aware datetimes). | |
| """ | |
| from contextlib import asynccontextmanager | |
| from fastapi import FastAPI | |
| from tortoise import Tortoise | |
| from fastapi_fullauth.middleware import SecurityHeadersMiddleware | |
| from .auth import fullauth | |
| from .config import DATABASE_URL, MODELS_MODULE | |
| from .routes import router | |
| async def lifespan(app: FastAPI): | |
| await Tortoise.init(db_url=DATABASE_URL, modules={"models": [MODELS_MODULE]}) | |
| await Tortoise.generate_schemas(safe=True) # dev only; use migrations in production | |
| yield | |
| # init_app() wraps this lifespan to run fullauth.aclose() on shutdown, so | |
| # only the Tortoise teardown is needed here. | |
| await Tortoise.close_connections() | |
| app = FastAPI(title="FullAuth Tortoise Demo", lifespan=lifespan) | |
| app.add_middleware(SecurityHeadersMiddleware) | |
| fullauth.init_app(app) | |
| app.include_router(router) | |
Xet Storage Details
- Size:
- 1.02 kB
- Xet hash:
- 91d9671b92d8162f7d3ece31de27cf0fd502e41376999e2dcb3c72f475927c9b
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.