Skip to content
Myr

formatting

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

[ci skip]

authored by David Lord · committed by David Lord · parent 53ff054 · Browse files · 1 file+16 added−16 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+16 added−16 removed

  • other:+16 added−16 removed

1 file+16 added−16 removed

modified:docs/config.rst+16 added-16 removed
373 unmodified lines
374methods on the config object as well to load from individual files. For a375complete reference, read the :class:`~flask.Config` object's376documentation.377378Configuring from Environmental Variables379----------------------------------------378Configuring from Environment Variables379--------------------------------------380381In addition to pointing to configuration files using environment variables, you382may find it useful (or necessary) to control your configuration values383directly from the environment.382may find it useful (or necessary) to control your configuration values directly383from the environment.384385Environment variables can be set on Linux or OS X with the export command in the386shell before starting the server::385Environment variables can be set on Linux or OS X with the export command in386the shell before starting the server::387388 $ export SECRET_KEY='?\xbf,\xb4\x8d\xa3"<\x9c\xb0@\x0f5\xab,w\xee\x8d$0\x13\x8b83'389 $ export DEBUG=False390 $ python run-app.py
5 unmodified lines
396 >set SECRET_KEY='?\xbf,\xb4\x8d\xa3"<\x9c\xb0@\x0f5\xab,w\xee\x8d$0\x13\x8b83'397 >set DEBUG=False398399While this approach is straightforward to use, it is important to remember that400environment variables are strings -- they are not automatically deserialized into Python401types.400environment variables are strings -- they are not automatically deserialized401into Python types.402403Here is an example of a configuration file that uses environmental variables::403Here is an example of a configuration file that uses environment variables::404405 # Example configuration406 import os407
6 unmodified lines
414 if not SECRET_KEY:415 raise ValueError("No secret key set for Flask application")416417418Notice that any value besides an empty string will be interpreted as a boolean True value in Python, which419requires care if an environment explicitly sets values intended to be False.418Notice that any value besides an empty string will be interpreted as a boolean419``True`` value in Python, which requires care if an environment explicitly sets420values intended to be ``False``.421421Make sure to load the configuration very early on, so that extensions have422the ability to access the configuration when starting up. There are other423methods on the config object as well to load from individual files. For a424complete reference, read the :class:`~flask.Config` object's425documentation.422Make sure to load the configuration very early on, so that extensions have the423ability to access the configuration when starting up. There are other methods424on the config object as well to load from individual files. For a complete425reference, read the :class:`~flask.Config` class documentation.426427Configuration Best Practices428----------------------------429
168 unmodified lines