forked from orbit-oss/flask
Merge branch 'master' of github.com:mitsuhiko/flask
This commit is contained in:
commit
30d9efb24a
5 changed files with 13 additions and 11 deletions
|
|
@ -82,7 +82,7 @@ things (:ref:`app-factories`).
|
|||
The Routing System
|
||||
------------------
|
||||
|
||||
Flask uses the Werkzeug routing system which has was designed to
|
||||
Flask uses the Werkzeug routing system which was designed to
|
||||
automatically order routes by complexity. This means that you can declare
|
||||
routes in arbitrary order and they will still work as expected. This is a
|
||||
requirement if you want to properly implement decorator based routing
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ dictionary and put it somewhere else::
|
|||
def pull_lang_code(endpoint, values):
|
||||
g.lang_code = values.pop('lang_code', None)
|
||||
|
||||
That way you no longer have to do the `lang_code` assigment to
|
||||
That way you no longer have to do the `lang_code` assignment to
|
||||
:data:`~flask.g` in every function. You can further improve that by
|
||||
writing your own decorator that prefixes URLs with the language code, but
|
||||
the more beautiful solution is using a blueprint. Once the
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ So what did that code do?
|
|||
5. Finally we use the :meth:`~flask.Flask.run` function to run the local server
|
||||
with our application. The ``if __name__ == '__main__':`` makes sure the
|
||||
server only runs if the script is executed directly from the Python
|
||||
interpreter and not used as imported module.
|
||||
interpreter and not used as an imported module.
|
||||
|
||||
To stop the server, hit control-C.
|
||||
|
||||
|
|
@ -143,8 +143,8 @@ Variable Rules
|
|||
``````````````
|
||||
|
||||
To add variable parts to a URL you can mark these special sections as
|
||||
``<variable_name>``. Such a part is then passed as keyword argument to your
|
||||
function. Optionally a converter can be specified by specifying a rule with
|
||||
``<variable_name>``. Such a part is then passed as a keyword argument to your
|
||||
function. Optionally a converter can be used by specifying a rule with
|
||||
``<converter:variable_name>``. Here are some nice examples::
|
||||
|
||||
@app.route('/user/<username>')
|
||||
|
|
@ -191,10 +191,10 @@ The following converters exist:
|
|||
rather like the pathname of a file on UNIX-like systems. Accessing the URL
|
||||
with a trailing slash will produce a 404 "Not Found" error.
|
||||
|
||||
This behavior allows relative URLs to continue working if users access the
|
||||
page when they forget a trailing slash, consistent with how Apache
|
||||
and other servers work. Also, the URLs will stay unique, which helps search
|
||||
engines avoid indexing the same page twice.
|
||||
This behavior allows relative URLs to continue working even if the trailing
|
||||
slash is ommited, consistent with how Apache and other servers work. Also,
|
||||
the URLs will stay unique, which helps search engines avoid indexing the
|
||||
same page twice.
|
||||
|
||||
|
||||
.. _url-building:
|
||||
|
|
|
|||
|
|
@ -141,6 +141,8 @@ def jsonify(*args, **kwargs):
|
|||
to this function are the same as to the :class:`dict` constructor.
|
||||
|
||||
Example usage::
|
||||
|
||||
from flask import jsonify
|
||||
|
||||
@app.route('/_get_current_user')
|
||||
def get_current_user():
|
||||
|
|
|
|||
4
setup.py
4
setup.py
|
|
@ -8,7 +8,7 @@ intentions. And before you ask: It's BSD licensed!
|
|||
Flask is Fun
|
||||
````````````
|
||||
|
||||
::
|
||||
.. code:: python
|
||||
|
||||
from flask import Flask
|
||||
app = Flask(__name__)
|
||||
|
|
@ -23,7 +23,7 @@ Flask is Fun
|
|||
And Easy to Setup
|
||||
`````````````````
|
||||
|
||||
::
|
||||
.. code:: bash
|
||||
|
||||
$ pip install Flask
|
||||
$ python hello.py
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue