33 lines
722 B
Python
33 lines
722 B
Python
"""
|
|
Configuration definition.
|
|
|
|
Converts per-run (environment) variables and config files into the
|
|
"python world" using `pydantic`.
|
|
|
|
Pydantic models might have convenience methods attached.
|
|
"""
|
|
|
|
from pathlib import Path
|
|
|
|
from pydantic import BaseSettings
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""
|
|
Per-run settings
|
|
"""
|
|
|
|
production_mode: bool = False
|
|
data_dir: Path = Path("./tmp")
|
|
config_file_name: Path = Path("config.json")
|
|
api_v1_prefix: str = "api/v1"
|
|
openapi_url: str = "/openapi.json"
|
|
docs_url: str | None = "/docs"
|
|
redoc_url: str | None = "/redoc"
|
|
|
|
@property
|
|
def config_file(self) -> Path:
|
|
return self.data_dir.joinpath(self.config_file_name)
|
|
|
|
|
|
SETTINGS = Settings()
|