Skip to content
Myr

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 0973536, 1441e02 · Browse files · 5 files+13 added−11 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+13 added−11 removed

  • other:+13 added−11 removed

5 files+13 added−11 removed

modified:docs/patterns/urlprocessors.rst+1 added-1 removed
63 unmodified lines
64 @app.url_value_preprocessor65 def pull_lang_code(endpoint, values):66 g.lang_code = values.pop('lang_code', None)6768That way you no longer have to do the `lang_code` assigment to68That way you no longer have to do the `lang_code` assignment to69:data:`~flask.g` in every function. You can further improve that by70writing your own decorator that prefixes URLs with the language code, but71the more beautiful solution is using a blueprint. Once the72``'lang_code'`` is popped from the values dictionary and it will no longer
54 unmodified lines
modified:docs/design.rst+1 added-1 removed
80 unmodified lines
8182The Routing System83------------------8485Flask uses the Werkzeug routing system which has was designed to85Flask uses the Werkzeug routing system which was designed to86automatically order routes by complexity. This means that you can declare87routes in arbitrary order and they will still work as expected. This is a88requirement if you want to properly implement decorator based routing89since decorators could be fired in undefined order when the application is
102 unmodified lines
modified:docs/quickstart.rst+7 added-7 removed
52 unmodified lines
53 user's browser.545. Finally we use the :meth:`~flask.Flask.run` function to run the local server55 with our application. The ``if __name__ == '__main__':`` makes sure the56 server only runs if the script is executed directly from the Python57 interpreter and not used as imported module.57 interpreter and not used as an imported module.5859To stop the server, hit control-C.6061.. _public-server:
80 unmodified lines
142Variable Rules143``````````````144145To add variable parts to a URL you can mark these special sections as146``<variable_name>``. Such a part is then passed as keyword argument to your147function. Optionally a converter can be specified by specifying a rule with146``<variable_name>``. Such a part is then passed as a keyword argument to your147function. Optionally a converter can be used by specifying a rule with148``<converter:variable_name>``. Here are some nice examples::149150 @app.route('/user/<username>')151 def show_user_profile(username):
38 unmodified lines
190 In the second case, however, the URL is defined without a trailing slash,191 rather like the pathname of a file on UNIX-like systems. Accessing the URL192 with a trailing slash will produce a 404 "Not Found" error.193194 This behavior allows relative URLs to continue working if users access the195 page when they forget a trailing slash, consistent with how Apache196 and other servers work. Also, the URLs will stay unique, which helps search197 engines avoid indexing the same page twice.194 This behavior allows relative URLs to continue working even if the trailing195 slash is ommited, consistent with how Apache and other servers work. Also, 196 the URLs will stay unique, which helps search engines avoid indexing the 197 same page twice.198199200.. _url-building:201
651 unmodified lines
modified:flask/json.py+2 added
139 unmodified lines
140 the given arguments with an `application/json` mimetype. The arguments141 to this function are the same as to the :class:`dict` constructor.142143 Example usage::144 145 from flask import jsonify146147 @app.route('/_get_current_user')148 def get_current_user():149 return jsonify(username=g.user.username,
20 unmodified lines
modified:setup.py+2 added-2 removed
6 unmodified lines
78Flask is Fun9````````````1011::11.. code:: python1213 from flask import Flask14 app = Flask(__name__)15
6 unmodified lines
2223And Easy to Setup24`````````````````2526::26.. code:: bash2728 $ pip install Flask29 $ python hello.py30 * Running on http://localhost:5000/
82 unmodified lines