Flask - Accessing the config variable in the template Flask - Accessing the config variable in the template flask flask

Flask - Accessing the config variable in the template


There are a few global variables that are passed in the templates context by default by flask (here is the complete list), one of them being config, which allows you to access the application configuration from templates. Being a dictionary, it can be accessed using the syntax config['MY_CONFIGURATION'] or config.MY_CONFIGURATION (this syntax for accessing dict items is specific to Jinja).

On the other hand, if you wanted to pass arbitrary data to your templates without having to pass it explicitely in each view, you would have to use context processors.