Browse Source

Update appfactories.rst

pull/2500/head
Bogdan Alexandru Marginean 7 years ago committed by GitHub
parent
commit
b89cf95816
  1. 21
      docs/patterns/appfactories.rst

21
docs/patterns/appfactories.rst

@ -89,10 +89,9 @@ For more information about the design of extensions refer to :doc:`/extensiondev
Using Applications Using Applications
------------------ ------------------
So to use such an application you then have to create the application To use such an application you have to create it in a separate file first,
first in a separate file otherwise the :command:`flask` command won't be able otherwise the :command:`flask` command won't be able to find it. Here's an
to find it. Here an example :file:`exampleapp.py` file that creates such example :file:`exampleapp.py` file that creates such an application::
an application::
from yourapplication import create_app from yourapplication import create_app
app = create_app('/path/to/config.cfg') app = create_app('/path/to/config.cfg')
@ -105,12 +104,12 @@ It can then be used with the :command:`flask` command::
Factory Improvements Factory Improvements
-------------------- --------------------
The factory function from above is not very clever so far, you can improve The factory function above is not very clever, but you can improve it.
it. The following changes are straightforward and possible: The following changes are straightforward to implement:
1. make it possible to pass in configuration values for unittests so that 1. Make it possible to pass in configuration values for unit tests so that
you don't have to create config files on the filesystem you don't have to create config files on the filesystem.
2. call a function from a blueprint when the application is setting up so 2. Call a function from a blueprint when the application is setting up so
that you have a place to modify attributes of the application (like that you have a place to modify attributes of the application (like
hooking in before / after request handlers etc.) hooking in before/after request handlers etc.)
3. Add in WSGI middlewares when the application is creating if necessary. 3. Add in WSGI middlewares when the application is being created if necessary.

Loading…
Cancel
Save