user12967240
user12967240

Reputation:

Uwsgi environmental variables

I,m stuck with my flask uwsgi application, which cannot see environmental variables, i put those in .bash_profile file, like export key="variable", and typed source ~/.bash_profile, but no effect.

Upvotes: 0

Views: 948

Answers (2)

Eric Milliot-Martinez
Eric Milliot-Martinez

Reputation: 4596

[uwsgi]

base = /var/www/html/poopbuddy-api

chdir = %(base)

app = app

I'm not sure exactly what chdir does, but I think it sets the default path to the root folder of the application, from there, load_dotenv() now works for me.

Upvotes: 0

Atte
Atte

Reputation: 308

One possible solution would be to use python-dotenv, add your environment variables to a .env file and then, in your config.py or whatever you use for loading environment variables, import it and call load_dotenv(). Then you can use variable = os.getenv('variable_declared_in_dotenv') to load it.

Upvotes: 1

Related Questions