Skip to content
Myr

Merge pull request #800 from nZac/issue#783

Before adoption: this commit came in with the history the project adopted, so no landing records it.

cleared up confusion for from_envvar in docs

authored by Armin Ronacher · committed by Armin Ronacher · parents c541f7e, 5ace060 · Browse files · 1 file+7 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+7 added−7 removed

  • other:+7 added−7 removed

1 file+7 added−7 removed

modified:docs/tutorial/setup.rst+7 added-7 removed
35 unmodified lines
36string it will import it) and then look for all uppercase variables37defined there. In our case, the configuration we just wrote a few lines38of code above. You can also move that into a separate file.3940Usually, it is a good idea to load a configuration from a configurable41file. This is what :meth:`~flask.Config.from_envvar` can do, replacing the42:meth:`~flask.Config.from_object` line above::4340Usually, it is a good idea to load a separate, environment specific41configuration file. Flask allows you to import multiple configurations and it 42will use the setting defined in the last import. This enables robust 43configuration setups. :meth:`~flask.Config.from_envvar` can help achieve this. 44 45 app.config.from_envvar('FLASKR_SETTINGS', silent=True)4646That way someone can set an environment variable called47:envvar:`FLASKR_SETTINGS` to specify a config file to be loaded which will then48override the default values. The silent switch just tells Flask to not complain47Simply define the environment variable :envvar:`FLASKR_SETTINGS` that points to 48a config file to be loaded. The silent switch just tells Flask to not complain 49if no such environment key is set.5051The `secret_key` is needed to keep the client-side sessions secure.52Choose that key wisely and as hard to guess and complex as possible. The
38 unmodified lines