Merge branch 'master' of github.com:mitsuhiko/flask
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Armin Ronacher · committed by Armin Ronacher · parents a5da2c9, 1bca65d · Browse files · 2 files·+21 added−19 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+21 added−19 removed
- other:+21 added−19 removed
Provenance
- Commit
f0c089f- Tree
864b511- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent 1
a5da2c9- Parent 2
1bca65d
2 files changed+21 added−19 removed
modified:docs/deploying/uwsgi.rst+1 added-1 removed
34 unmodified lines35 Or, if you prefer:36 37 .. sourcecode:: text38 39- $ uwsgi -s /tmp/uwsgi.sock myapp:app39+ $ uwsgi -s /tmp/uwsgi.sock -w myapp:app40 41 Configuring nginx42 -----------------43 25 unmodified linesmodified:docs/config.rst+20 added-18 removed
3 unmodified lines4 ======================5 6 .. versionadded:: 0.37 8-Applications need some kind of configuration. There are different things9-you might want to change like toggling debug mode, the secret key, and a10-lot of very similar things.8+Applications need some kind of configuration. There are different settings9+you might want to change depending on the application environment like10+toggling the debug mode, setting the secret key, and other such11+environment-specific things.12 13 The way Flask is designed usually requires the configuration to be14 available when the application starts up. You can hardcode the15 configuration in the code, which for many small applications is not15 unmodified lines31 app = Flask(__name__)32 app.config['DEBUG'] = True33 34 Certain configuration values are also forwarded to the34-:attr:`~flask.Flask` object so that you can read and write them from35-there::35+:attr:`~flask.Flask` object so you can read and write them from there::36 37 app.debug = True38 39 To update multiple keys at once you can use the :meth:`dict.update`106 unmodified lines146 147 Configuring from Files148 ----------------------149 150-Configuration becomes more useful if you can configure from a file, and151-ideally that file would be outside of the actual application package so that152-you can install the package with distribute (:ref:`distribute-deployment`)153-and still modify that file afterwards.150+Configuration becomes more useful if you can store it in a separate file,151+ideally located outside the actual application package. This makes152+packaging and distributing your application possible via various package153+handling tools (:ref:`distribute-deployment`) and finally modifying the154+configuration file afterwards.155 156 So a common pattern is this::157 158 app = Flask(__name__)19 unmodified lines178 The configuration files themselves are actual Python files. Only values179 in uppercase are actually stored in the config object later on. So make180 sure to use uppercase letters for your config keys.181 181-Here is an example configuration file::182+Here is an example of a configuration file::183 184+ # Example configuration185 DEBUG = False186 SECRET_KEY = '?\xbf,\xb4\x8d\xa3"<\x9c\xb0@\x0f5\xab,w\xee\x8d$0\x13\x8b83'187 186-Make sure to load the configuration very early on so that extensions have188+Make sure to load the configuration very early on, so that extensions have189 the ability to access the configuration when starting up. There are other190 methods on the config object as well to load from individual files. For a191 complete reference, read the :class:`~flask.Config` object's192 documentation.2 unmodified lines195 Configuration Best Practices196 ----------------------------197 198 The downside with the approach mentioned earlier is that it makes testing197-a little harder. There is no one 100% solution for this problem in198-general, but there are a couple of things you can do to improve that199-experience:199+a little harder. There is no single 100% solution for this problem in200+general, but there are a couple of things you can keep in mind to improve201+that experience:202 203 1. create your application in a function and register blueprints on it.204 That way you can create multiple instances of your application with205 different configurations attached which makes unittesting a lot6 unmodified lines212 213 Development / Production214 ------------------------215 214-Most applications need more than one configuration. There will at least215-be a separate configuration for a production server and one used during216-development. The easiest way to handle this is to use a default217-configuration that is always loaded and part of version control, and a216+Most applications need more than one configuration. There should be at217+least separate configurations for the production server and the one used218+during development. The easiest way to handle this is to use a default219+configuration that is always loaded and part of the version control, and a220 separate configuration that overrides the values as necessary as mentioned221 in the example above::222 223 app = Flask(__name__)128 unmodified lines