Merge branch '1.0.x' into 1.1.x
This commit is contained in:
commit
746d9181d7
9 changed files with 71 additions and 71 deletions
|
|
@ -62,12 +62,12 @@ dispatched based on prefix.
|
|||
For example you could have your main application run on ``/`` and your
|
||||
backend interface on ``/backend``::
|
||||
|
||||
from werkzeug.wsgi import DispatcherMiddleware
|
||||
from werkzeug.middleware.dispatcher import DispatcherMiddleware
|
||||
from frontend_app import application as frontend
|
||||
from backend_app import application as backend
|
||||
|
||||
application = DispatcherMiddleware(frontend, {
|
||||
'/backend': backend
|
||||
'/backend': backend
|
||||
})
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ Alternatively you can register `uploaded_file` as `build_only` rule and
|
|||
use the :class:`~werkzeug.wsgi.SharedDataMiddleware`. This also works with
|
||||
older versions of Flask::
|
||||
|
||||
from werkzeug import SharedDataMiddleware
|
||||
from werkzeug.middleware.shared_data import SharedDataMiddleware
|
||||
app.add_url_rule('/uploads/<filename>', 'uploaded_file',
|
||||
build_only=True)
|
||||
app.wsgi_app = SharedDataMiddleware(app.wsgi_app, {
|
||||
|
|
|
|||
|
|
@ -3,15 +3,16 @@
|
|||
Patterns for Flask
|
||||
==================
|
||||
|
||||
Certain things are common enough that the chances are high you will find
|
||||
them in most web applications. For example quite a lot of applications
|
||||
are using relational databases and user authentication. In that case,
|
||||
chances are they will open a database connection at the beginning of the
|
||||
request and get the information of the currently logged in user. At the
|
||||
end of the request, the database connection is closed again.
|
||||
Certain features and interactions are common enough that you will find
|
||||
them in most web applications. For example, many applications use a
|
||||
relational database and user authentication. They will open a database
|
||||
connection at the beginning of the request and get the information for
|
||||
the logged in user. At the end of the request, the database connection
|
||||
is closed.
|
||||
|
||||
There are more user contributed snippets and patterns in the `Flask
|
||||
Snippet Archives <http://flask.pocoo.org/snippets/>`_.
|
||||
These types of patterns may be a bit outside the scope of Flask itself,
|
||||
but Flask makes it easy to implement them. Some common patterns are
|
||||
collected in the following pages.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ loaded upfront. The trick is to actually load the view function as needed.
|
|||
This can be accomplished with a helper class that behaves just like a
|
||||
function but internally imports the real function on first use::
|
||||
|
||||
from werkzeug import import_string, cached_property
|
||||
from werkzeug.utils import import_string, cached_property
|
||||
|
||||
class LazyView(object):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue