update patterns, snippets, extensions docs

This commit is contained in:
David Lord 2019-09-23 08:19:40 -07:00
parent c074422cfd
commit e01b68e7ee
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
9 changed files with 71 additions and 71 deletions

View file

@ -824,16 +824,22 @@ docs for more information.
Read more on :ref:`application-errors`.
Hooking in WSGI Middlewares
---------------------------
Hooking in WSGI Middleware
--------------------------
If you want to add a WSGI middleware to your application you can wrap the
internal WSGI application. For example if you want to use one of the
middlewares from the Werkzeug package to work around bugs in lighttpd, you
can do it like this::
To add WSGI middleware to your Flask application, wrap the application's
``wsgi_app`` attribute. For example, to apply Werkzeug's
:class:`~werkzeug.middlware.proxy_fix.ProxyFix` middleware for running
behind Nginx:
from werkzeug.contrib.fixers import LighttpdCGIRootFix
app.wsgi_app = LighttpdCGIRootFix(app.wsgi_app)
.. code-block:: python
from werkzeug.middleware.proxy_fix import ProxyFix
app.wsgi_app = ProxyFix(app.wsgi_app)
Wrapping ``app.wsgi_app`` instead of ``app`` means that ``app`` still
points at your Flask application, not at the middleware, so you can
continue to use and configure ``app`` directly.
Using Flask Extensions
----------------------