From b23d45ddfb3ca62ba187abcf3bf49650b817091b Mon Sep 17 00:00:00 2001 From: Parham Alvani Date: Sat, 9 Mar 2024 03:56:39 +0000 Subject: [PATCH] chore: handle environment variables for configuration --- app/config.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/config.py b/app/config.py index a6deb67..ed88847 100644 --- a/app/config.py +++ b/app/config.py @@ -17,11 +17,17 @@ class HTTP(pydantic.BaseModel): class Settings(pydantic_settings.BaseSettings): """ - Configuration holder + Configuration holder which reads configuration from config.toml + and environment variables. """ http: HTTP = HTTP(debug=True) - model_config = pydantic_settings.SettingsConfigDict(toml_file="config.toml") + model_config = pydantic_settings.SettingsConfigDict( + toml_file="config.toml", + env_prefix="fastapi101_", + case_sensitive=False, + env_nested_delimiter="__", + ) @classmethod def settings_customise_sources(