I have a WSGI handler configured under Apache and I'm defining some environmental variables in the Apache virtual host configuration.
SetEnv APP_CONFIG "/var/lib/myapp/app.config"
SetEnv LOG_CONFIG "/var/lib/myapp/app.logging.yml"
To test the handler in development without having to install and configure Apache I'm using uWSGI
with the --http
option.
uwsgi --http :9090 --ini uwsgi.ini --wsgi-file wsgi.py
wsgi.py
def application(environ, start_response):
config_file_path = environ['APP_CONFIG']
start_response('200 OK', [('Content-Type','text/html')])
return ["Hello World"]
Using the uWSGI http server how can I pass these variables to my application as part of the environ
argument?
I have tried setting environmental variables in the uwsgi.ini file:
[uwsgi]
env = APP_CONFIG="/var/lib/myapp/app.config"
but I get:
File "wsgi.py", line 5, in application
config_file_path = environ['APP_CONFIG']
KeyError: 'APP_CONFIG'