fastapi-boilerplate
fastapi-boilerplate copied to clipboard
Config file not working?
Hi.
In the main.py file there is an import from core.config import config
, which means that get_config() is being executed before os.environ["ENV"] = env
from main(), so I always end up with "development" from ENV: str = "development"
.
Am I missing something?
I noticed the exact same thing. Setting the environment variable via ENV=prod python main.py
works, while python main.py --env prod
does not, due to the execution order of get_config()
that you mentioned, which determines the config based on the environment variable ENV
.
Я заметил то же самое. Установка переменной среды через
ENV=prod python main.py
работает, аpython main.py --env prod
не из-за упомянутого вами порядка выполненияget_config()
, который определяет конфигурацию на основе переменной средыENV
.
How fix it?