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
Provenance
- Commit
30d9efb- Tree
568664a- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent 1
0973536- Parent 2
1441e02
5 files changed+13 added−11 removed
modified:docs/patterns/urlprocessors.rst+1 added-1 removed
63 unmodified lines64 @app.url_value_preprocessor65 def pull_lang_code(endpoint, values):66 g.lang_code = values.pop('lang_code', None)67 68-That way you no longer have to do the `lang_code` assigment to68+That way you no longer have to do the `lang_code` assignment to69 :data:`~flask.g` in every function. You can further improve that by70 writing your own decorator that prefixes URLs with the language code, but71 the more beautiful solution is using a blueprint. Once the72 ``'lang_code'`` is popped from the values dictionary and it will no longer54 unmodified linesmodified:docs/design.rst+1 added-1 removed
80 unmodified lines81 82 The Routing System83 ------------------84 85-Flask uses the Werkzeug routing system which has was designed to85+Flask uses the Werkzeug routing system which was designed to86 automatically order routes by complexity. This means that you can declare87 routes in arbitrary order and they will still work as expected. This is a88 requirement if you want to properly implement decorator based routing89 since decorators could be fired in undefined order when the application is102 unmodified linesmodified:docs/quickstart.rst+7 added-7 removed
52 unmodified lines53 user's browser.54 5. 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.58 59 To stop the server, hit control-C.60 61 .. _public-server:80 unmodified lines142 Variable Rules143 ``````````````144 145 To 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 your147-function. Optionally a converter can be specified by specifying a rule with146+``<variable_name>``. Such a part is then passed as a keyword argument to your147+function. Optionally a converter can be used by specifying a rule with148 ``<converter:variable_name>``. Here are some nice examples::149 150 @app.route('/user/<username>')151 def show_user_profile(username):38 unmodified lines190 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.193 194- 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.198 199 200 .. _url-building:201 651 unmodified linesmodified:flask/json.py+2 added
139 unmodified lines140 the given arguments with an `application/json` mimetype. The arguments141 to this function are the same as to the :class:`dict` constructor.142 143 Example usage::144+ 145+ from flask import jsonify146 147 @app.route('/_get_current_user')148 def get_current_user():149 return jsonify(username=g.user.username,20 unmodified linesmodified:setup.py+2 added-2 removed
6 unmodified lines7 8 Flask is Fun9 ````````````10 11-::11+.. code:: python12 13 from flask import Flask14 app = Flask(__name__)15 6 unmodified lines22 23 And Easy to Setup24 `````````````````25 26-::26+.. code:: bash27 28 $ pip install Flask29 $ python hello.py30 * Running on http://localhost:5000/82 unmodified lines