mirror of
https://github.com/fastapi/fastapi.git
synced 2026-06-04 21:55:24 -04:00
* Add doc and example for env var config * Syntax highlight for .env file * Add test for configuration docs * 📝 Update settings docs, add more examples * ✅ Add tests for settings * 🚚 Rename "Application Configuration" to "Metadata and Docs URLs" to disambiguate between that and settings * 🔥 Remove replaced example file Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
22 lines
461 B
Python
22 lines
461 B
Python
from fastapi import Depends, FastAPI
|
|
|
|
from . import config
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
def get_settings():
|
|
if config.settings:
|
|
return config.settings
|
|
config.settings = config.Settings()
|
|
return config.settings
|
|
|
|
|
|
@app.get("/info")
|
|
async def info(settings: config.Settings = Depends(get_settings)):
|
|
return {
|
|
"app_name": settings.app_name,
|
|
"admin_email": settings.admin_email,
|
|
"items_per_user": settings.items_per_user,
|
|
}
|