Skip to content

Instantly share code, notes, and snippets.

@francbartoli
Forked from wshayes/appsettings.py
Created June 2, 2019 12:39
Show Gist options
  • Save francbartoli/d5eb24185c65d36c0580a7193d0e3c17 to your computer and use it in GitHub Desktop.
Save francbartoli/d5eb24185c65d36c0580a7193d0e3c17 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