Re: [flask] Accessing WSGI environment variables
- Drew Vogel
- 2011-03-22 @ 00:48
On Mon, Mar 21, 2011 at 7:02 PM, Kenshi Kawaguchi <firstname.lastname@example.org> wrote:
> According to the mod_wsgi docs (
> http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines) it looks
> like environment variables set using SetEnv in Apache are not accessible
> using os.environ,
> Any such variables added using the SetEnv directive will be automatically
>> added to the WSGI environment passed to the application when executed.
>> Note that the WSGI environment is passed upon each request to the
>> application in the 'environ' argument of the application object. This
>> environment is totally unrelated to the process environment which is kept in
>> 'os.environ'. The SetEnv directive has no effect on 'os.environ' and there
>> is no way through Apache configuration directives to affect what is in the
>> process environment.
> What's the best way to access these variables through Flask?
The WSGI environ parameter is available as Request.environ. For more info
see the Werkzeug documentation: