Skip to content

Instantly share code, notes, and snippets.

@wshayes
Created May 30, 2019 14:17
Show Gist options
  • Select an option

  • Save wshayes/306f5752cc0f64a390a64ad5c2241b38 to your computer and use it in GitHub Desktop.

Select an option

Save wshayes/306f5752cc0f64a390a64ad5c2241b38 to your computer and use it in GitHub Desktop.
[App Settings] app settings using pydantic #fastapi
class AppSettings(BaseSettings):
project_name: Optional[str]
debug: bool = False
include_admin_routes: bool = False
# Server
server_name: Optional[str]
server_host: Optional[str]
sentry_dsn: Optional[str]
backend_cors_origins_str: str = "" # Should be a comma-separated list of origins
secret_key: bytes = os.urandom(32)
# URLs
api_v1_str: str = "/api/v1"
openapi_url: str = "/api/v1/openapi.json"
# Database
postgres_server: Optional[str]
postgres_user: Optional[str]
postgres_password: Optional[str]
postgres_db: Optional[str]
...
class Config:
env_prefix = "" # defaults to 'APP_'
settings = AppSettings()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment