quickstart.rst
This file
Path
docs/quickstart.rst
748 lines · 26.9 KiB
Last changed by
Added templating docs. This basically fixes #92Armin Ronacherbefore adoption4a2d2ba
History of this fileTake it
The walk stopped after 200 commits: lines older than cc7876f point at it.
Fix in docs for handle_exception: "A" before nouns pronounced with an initial consonant soundDag Odenhallbefore adoptioncc7876f
lines 1–40why, one step back1.. _quickstart:23Quickstart4==========56Eager to get started? This page gives a good introduction in how to gets7started with Flask. This assumes you already have Flask installed. If8you do not, head over to the :ref:`installation` section.91011A Minimal Application12---------------------1314A minimal Flask application looks something like that::1516 from flask import Flask17 app = Flask(__name__)1819 @app.route('/')20 def hello_world():21 return "Hello World!"2223 if __name__ == '__main__':24 app.run()2526Just save it as `hello.py` or something similar and run it with your27Python interpreter. Make sure to not call your application `flask.py`28because this would conflict with Flask itself.2930::3132 $ python hello.py33 * Running on http://127.0.0.1:5000/3435Head over to `http://127.0.0.1:5000/ <http://127.0.0.1:5000/>`_, you should36see your hello world greeting.3738So what did that code do?39401. first we imported the :class:`~flask.Flask` class. An instance of thisExplained Flask constructor better. This fixes #70Armin Ronacherbefore adoption3ab318a
lines 41–46why, one step back41 class will be our WSGI application. The first argument is the name of42 the application's module. If you are using a single module (like here)43 you should use `__name__` because depending on if it's started as44 application or imported as module the name will be different45 (``'__main__'`` versus the actual import name). For more information46 on that, have a look at the :class:`~flask.Flask` documentation.Fix in docs for handle_exception: "A" before nouns pronounced with an initial consonant soundDag Odenhallbefore adoptioncc7876f
lines 47–271why, one step back472. next we create an instance of it. We pass it the name of the module /48 package. This is needed so that Flask knows where it should look for49 templates, static files and so on.503. Then we use the :meth:`~flask.Flask.route` decorator to tell Flask51 what URL should trigger our function.524. The function then has a name which is also used to generate URLs to53 that particular function, and returns the message we want to display in54 the user's browser.555. Finally we use the :meth:`~flask.Flask.run` function to run the56 local server with our application. The ``if __name__ == '__main__':``57 makes sure the server only runs if the script is executed directly from58 the Python interpreter and not used as imported module.5960To stop the server, hit control-C.6162.. _public-server:6364.. admonition:: Externally Visible Server6566 If you run the server you will notice that the server is only available67 from your own computer, not from any other in the network. This is the68 default because in debugging mode a user of the application can execute69 arbitrary Python code on your computer. If you have `debug` disabled70 or trust the users on your network, you can make the server publicly71 available.7273 Just change the call of the :meth:`~flask.Flask.run` method to look74 like this::7576 app.run(host='0.0.0.0')7778 This tells your operating system to listen on a public IP.798081Debug Mode82----------8384Now that :meth:`~flask.Flask.run` method is nice to start a local85development server, but you would have to restart it manually after each86change you do to code. That is not very nice and Flask can do better. If87you enable the debug support the server will reload itself on code changes88and also provide you with a helpful debugger if things go wrong.8990There are two ways to enable debugging. Either set that flag on the91application object::9293 app.debug = True94 app.run()9596Or pass it to run::9798 app.run(debug=True)99100Both will have exactly the same effect.101102.. admonition:: Attention103104 The interactive debugger however does not work in forking environments105 which makes it nearly impossible to use on production servers but the106 debugger still allows the execution of arbitrary code which makes it a107 major security risk and **must never be used on production machines**108 because of that.109110Screenshot of the debugger in action:111112.. image:: _static/debugger.png113 :align: center114 :class: screenshot115 :alt: screenshot of debugger in action116117118Routing119-------120121As you have seen above, the :meth:`~flask.Flask.route` decorator is used122to bind a function to a URL. But there is more to it! You can make123certain parts of the URL dynamic and attach multiple rules to a function.124125Here some examples::126127 @app.route('/')128 def index():129 return 'Index Page'130131 @app.route('/hello')132 def hello():133 return 'Hello World'134135136Variable Rules137``````````````138139Modern web applications have beautiful URLs. This helps people remember140the URLs which is especially handy for applications that are used from141mobile devices with slower network connections. If the user can directly142go to the desired page without having to hit the index page it is more143likely he will like the page and come back next time.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 to147your function. Optionally a converter can be specified by specifying a148rule with ``<converter:variable_name>``. Here some nice examples::149150 @app.route('/user/<username>')151 def show_user_profile(username):152 # show the user profile for that user153 pass154155 @app.route('/post/<int:post_id>')156 def show_post(post_id):157 # show the post with the given id, the id is an integer158 pass159160The following converters exist:161162=========== ===========================================163`int` accepts integers164`float` like `int` but for floating point values165`path` like the default but also accepts slashes166=========== ===========================================167168.. admonition:: Unique URLs / Redirection Behaviour169170 Flask's URL rules are based on Werkzeug's routing module. The idea171 behind that module is to ensure nice looking and also unique URLs based172 on behaviour Apache and earlier servers coined.173174 Take these two rules::175176 @app.route('/projects/')177 def projects():178 pass179180 @app.route('/about')181 def about():182 pass183184 They look rather similar, the difference is the trailing slash in the185 URL *definition*. In the first case, the canonical URL for the186 `projects` endpoint has a trailing slash. It's similar to a folder in187 that sense. Accessing it without a trailing slash will cause Flask to188 redirect to the canonical URL with the trailing slash.189190 However in the second case the URL is defined without a slash so it191 behaves similar to a file and accessing the URL with a trailing slash192 will be a 404 error.193194 Why is this? This allows relative URLs to continue working if users195 access the page when they forget a trailing slash. This behaviour is196 also consistent with how Apache and other servers work. Also, the URLs197 will stay unique which helps search engines not indexing the same page198 twice.199200201.. _url-building:202203URL Building204````````````205206If it can match URLs, can it also generate them? Of course you can. To207build a URL to a specific function you can use the :func:`~flask.url_for`208function. It accepts the name of the function as first argument and a209number of keyword arguments, each corresponding to the variable part of210the URL rule. Unknown variable parts are appended to the URL as query211parameter. Here some examples:212213>>> from flask import Flask, url_for214>>> app = Flask(__name__)215>>> @app.route('/')216... def index(): pass217...218>>> @app.route('/login')219... def login(): pass220...221>>> @app.route('/user/<username>')222... def profile(username): pass223...224>>> with app.test_request_context():225... print url_for('index')226... print url_for('login')227... print url_for('login', next='/')228... print url_for('profile', username='John Doe')229...230/231/login232/login?next=/233/user/John%20Doe234235(This also uses the :meth:`~flask.Flask.test_request_context` method236explained below. It basically tells flask to think we are handling a237request even though we are not, we are in an interactive Python shell.238Have a look at the explanation below. :ref:`context-locals`).239240Why would you want to build URLs instead of hardcoding them in your241templates? There are three good reasons for this:2422431. reversing is often more descriptive than hardcoding the URLs. Also and244 more importantly you can change URLs in one go without having to change245 the URLs all over the place.2462. URL building will handle escaping of special characters and Unicode247 data transparently for you, you don't have to deal with that.2483. If your application is placed outside the URL root (so say in249 ``/myapplication`` instead of ``/``), :func:`~flask.url_for` will250 handle that properly for you.251252253HTTP Methods254````````````255256HTTP (the protocol web applications are speaking) knows different methods257to access URLs. By default a route only answers to `GET` requests, but258that can be changed by providing the `methods` argument to the259:meth:`~flask.Flask.route` decorator. Here some examples::260261 @app.route('/login', methods=['GET', 'POST'])262 def login():263 if request.method == 'POST':264 do_the_login()265 else:266 show_the_login_form()267268If `GET` is present, `HEAD` will be added automatically for you. You269don't have to deal with that. It will also make sure that `HEAD` requests270are handled like the `HTTP RFC`_ (the document describing the HTTP271protocol) demands, so you can completely ignore that part of the HTTPAdded support for automagic OPTIONSArmin Ronacherbefore adoption5e1b103
lines 272–273why, one step back272specification. Likewise as of Flask 0.6, `OPTIONS` is implemented for you273as well automatically.Fix in docs for handle_exception: "A" before nouns pronounced with an initial consonant soundDag Odenhallbefore adoptioncc7876f
lines 274–312why, one step back274275You have no idea what an HTTP method is? Worry not, here quick276introduction in HTTP methods and why they matter:277278The HTTP method (also often called "the verb") tells the server what the279clients wants to *do* with the requested page. The following methods are280very common:281282`GET`283 The Browser tells the server: just *get* me the information stored on284 that page and send them to me. This is probably the most common285 method.286287`HEAD`288 The Browser tells the server: get me the information, but I am only289 interested in the *headers*, not the content of the page. An290 application is supposed to handle that as if a `GET` request was291 received but not deliver the actual contents. In Flask you don't have292 to deal with that at all, the underlying Werkzeug library handles that293 for you.294295`POST`296 The browser tells the server that it wants to *post* some new297 information to that URL and that the server must ensure the data is298 stored and only stored once. This is how HTML forms are usually299 transmitting data to the server.300301`PUT`302 Similar to `POST` but the server might trigger the store procedure303 multiple times by overwriting the old values more than once. Now you304 might be asking why this is any useful, but there are some good305 reasons to do that. Consider the connection is lost during306 transmission, in that situation a system between the browser and the307 server might sent the request safely a second time without breaking308 things. With `POST` that would not be possible because it must only309 be triggered once.310311`DELETE`312 Remove the information that the given location.Added support for automagic OPTIONSArmin Ronacherbefore adoption5e1b103
lines 313–317why, one step back313314`OPTIONS`315 Provides a quick way for a requesting client to figure out which316 methods are supported by this URL. Starting with Flask 0.6, this317 is implemented for you automatically.Fix in docs for handle_exception: "A" before nouns pronounced with an initial consonant soundDag Odenhallbefore adoptioncc7876f
lines 318–381why, one step back318319Now the interesting part is that in HTML4 and XHTML1, the only methods a320form might submit to the server are `GET` and `POST`. But with JavaScript321and future HTML standards you can use other methods as well. Furthermore322HTTP became quite popular lately and there are more things than browsers323that are speaking HTTP. (Your revision control system for instance might324speak HTTP)325326.. _HTTP RFC: http://www.ietf.org/rfc/rfc2068.txt327328Static Files329------------330331Dynamic web applications need static files as well. That's usually where332the CSS and JavaScript files are coming from. Ideally your web server is333configured to serve them for you, but during development Flask can do that334as well. Just create a folder called `static` in your package or next to335your module and it will be available at `/static` on the application.336337To generate URLs to that part of the URL, use the special ``'static'`` URL338name::339340 url_for('static', filename='style.css')341342The file has to be stored on the filesystem as ``static/style.css``.343344Rendering Templates345-------------------346347Generating HTML from within Python is not fun, and actually pretty348cumbersome because you have to do the HTML escaping on your own to keep349the application secure. Because of that Flask configures the `Jinja2350<http://jinja.pocoo.org/2/>`_ template engine for you automatically.351352To render a template you can use the :func:`~flask.render_template`353method. All you have to do is to provide the name of the template and the354variables you want to pass to the template engine as keyword arguments.355Here's a simple example of how to render a template::356357 from flask import render_template358359 @app.route('/hello/')360 @app.route('/hello/<name>')361 def hello(name=None):362 return render_template('hello.html', name=name)363364Flask will look for templates in the `templates` folder. So if your365application is a module, that folder is next to that module, if it's a366package it's actually inside your package:367368**Case 1**: a module::369370 /application.py371 /templates372 /hello.html373374**Case 2**: a package::375376 /application377 /__init__.py378 /templates379 /hello.html380381For templates you can use the full power of Jinja2 templates. Head overAdded templating docs. This basically fixes #92Armin Ronacherbefore adoption4a2d2ba
lines 382–383why, one step back382to the :ref:`templating` section of the documentation or the official383`Jinja2 Template DocumentationFix in docs for handle_exception: "A" before nouns pronounced with an initial consonant soundDag Odenhallbefore adoptioncc7876f
lines 384–423why, one step back384<http://jinja.pocoo.org/2/documentation/templates>`_ for more information.385386Here an example template:387388.. sourcecode:: html+jinja389390 <!doctype html>391 <title>Hello from Flask</title>392 {% if name %}393 <h1>Hello {{ name }}!</h1>394 {% else %}395 <h1>Hello World!</h1>396 {% endif %}397398Inside templates you also have access to the :class:`~flask.request`,399:class:`~flask.session` and :class:`~flask.g` [#]_ objects400as well as the :func:`~flask.get_flashed_messages` function.401402Templates are especially useful if inheritance is used. If you want to403know how that works, head over to the :ref:`template-inheritance` pattern404documentation. Basically template inheritance makes it possible to keep405certain elements on each page (like header, navigation and footer).406407Automatic escaping is enabled, so if name contains HTML it will be escaped408automatically. If you can trust a variable and you know that it will be409safe HTML (because for example it came from a module that converts wiki410markup to HTML) you can mark it as safe by using the411:class:`~jinja2.Markup` class or by using the ``|safe`` filter in the412template. Head over to the Jinja 2 documentation for more examples.413414Here a basic introduction in how the :class:`~jinja2.Markup` class works:415416>>> from flask import Markup417>>> Markup('<strong>Hello %s!</strong>') % '<blink>hacker</blink>'418Markup(u'<strong>Hello <blink>hacker</blink>!</strong>')419>>> Markup.escape('<blink>hacker</blink>')420Markup(u'<blink>hacker</blink>')421>>> Markup('<em>Marked up</em> » HTML').striptags()422u'Marked up \xbb HTML'423Started working on refactoring Jinja integrationArmin Ronacherbefore adoption7599046
lines 424–430why, one step back424.. versionchanged:: 0.5425426 Autoescaping is no longer enabled for all templates. The following427 extensions for templates trigger autoescaping: ``.html``, ``.htm``,428 ``.xml``, ``.xhtml``. Templates loaded from string will have429 autoescaping disabled.430Fix in docs for handle_exception: "A" before nouns pronounced with an initial consonant soundDag Odenhallbefore adoptioncc7876f
lines 431–582why, one step back431.. [#] Unsure what that :class:`~flask.g` object is? It's something you432 can store information on yourself, check the documentation of that433 object (:class:`~flask.g`) and the :ref:`sqlite3` for more434 information.435436437Accessing Request Data438----------------------439440For web applications it's crucial to react to the data a client sent to441the server. In Flask this information is provided by the global442:class:`~flask.request` object. If you have some experience with Python443you might be wondering how that object can be global and how Flask444manages to still be threadsafe. The answer are context locals:445446447.. _context-locals:448449Context Locals450``````````````451452.. admonition:: Insider Information453454 If you want to understand how that works and how you can implement455 tests with context locals, read this section, otherwise just skip it.456457Certain objects in Flask are global objects, but not just a standard458global object, but actually a proxy to an object that is local to a459specific context. What a mouthful. But that is actually quite easy to460understand.461462Imagine the context being the handling thread. A request comes in and the463webserver decides to spawn a new thread (or something else, the464underlying object is capable of dealing with other concurrency systems465than threads as well). When Flask starts its internal request handling it466figures out that the current thread is the active context and binds the467current application and the WSGI environments to that context (thread).468It does that in an intelligent way that one application can invoke another469application without breaking.470471So what does this mean to you? Basically you can completely ignore that472this is the case unless you are unittesting or something different. You473will notice that code that depends on a request object will suddenly break474because there is no request object. The solution is creating a request475object yourself and binding it to the context. The easiest solution for476unittesting is by using the :meth:`~flask.Flask.test_request_context`477context manager. In combination with the `with` statement it will bind a478test request so that you can interact with it. Here an example::479480 from flask import request481482 with app.test_request_context('/hello', method='POST'):483 # now you can do something with the request until the484 # end of the with block, such as basic assertions:485 assert request.path == '/hello'486 assert request.method == 'POST'487488The other possibility is passing a whole WSGI environment to the489:meth:`~flask.Flask.request_context` method::490491 from flask import request492493 with app.request_context(environ):494 assert request.method == 'POST'495496The Request Object497``````````````````498499The request object is documented in the API section and we will not cover500it here in detail (see :class:`~flask.request`), but just mention some of501the most common operations. First of all you have to import it from the502the `flask` module::503504 from flask import request505506The current request method is available by using the507:attr:`~flask.request.method` attribute. To access form data (data508transmitted in a `POST` or `PUT` request) you can use the509:attr:`~flask.request.form` attribute. Here a full example of the two510attributes mentioned above::511512 @app.route('/login', methods=['POST', 'GET'])513 def login():514 error = None515 if request.method == 'POST':516 if valid_login(request.form['username'],517 request.form['password']):518 return log_the_user_in(request.form['username'])519 else:520 error = 'Invalid username/password'521 # this is executed if the request method was GET or the522 # credentials were invalid523524What happens if the key does not exist in the `form` attribute? In that525case a special :exc:`KeyError` is raised. You can catch it like a526standard :exc:`KeyError` but if you don't do that, a HTTP 400 Bad Request527error page is shown instead. So for many situations you don't have to528deal with that problem.529530To access parameters submitted in the URL (``?key=value``) you can use the531:attr:`~flask.request.args` attribute::532533 searchword = request.args.get('q', '')534535We recommend accessing URL parameters with `get` or by catching the536`KeyError` because users might change the URL and presenting them a 400537bad request page in that case is a bit user unfriendly.538539For a full list of methods and attributes on that object, head over to the540:class:`~flask.request` documentation.541542543File Uploads544````````````545546Obviously you can handle uploaded files with Flask just as easy. Just547make sure not to forget to set the ``enctype="multipart/form-data"``548attribute on your HTML form, otherwise the browser will not transmit your549files at all.550551Uploaded files are stored in memory or at a temporary location on the552filesystem. You can access those files by looking at the553:attr:`~flask.request.files` attribute on the request object. Each554uploaded file is stored in that dictionary. It behaves just like a555standard Python :class:`file` object, but it also has a556:meth:`~werkzeug.FileStorage.save` method that allows you to store that557file on the filesystem of the server. Here a simple example how that558works::559560 from flask import request561562 @app.route('/upload', methods=['GET', 'POST'])563 def upload_file():564 if request.method == 'POST':565 f = request.files['the_file']566 f.save('/var/www/uploads/uploaded_file.txt')567 ...568569If you want to know how the file was named on the client before it was570uploaded to your application, you can access the571:attr:`~werkzeug.FileStorage.filename` attribute. However please keep in572mind that this value can be forged so never ever trust that value. If you573want to use the filename of the client to store the file on the server,574pass it through the :func:`~werkzeug.secure_filename` function that575Werkzeug provides for you::576577 from flask import request578 from werkzeug import secure_filename579580 @app.route('/upload', methods=['GET', 'POST'])581 def upload_file():582 if request.method == 'POST':Merge branch 'master' of github.com:mitsuhiko/flaskArmin Ronacherbefore adoption223d44d
line 583why, one step back583 f = request.files['the_file']Fix in docs for handle_exception: "A" before nouns pronounced with an initial consonant soundDag Odenhallbefore adoptioncc7876f
lines 584–649why, one step back584 f.save('/var/www/uploads/' + secure_filename(f.filename))585 ...586587For some better examples, checkout the :ref:`uploading-files` pattern.588589Cookies590```````591592To access cookies you can use the :attr:`~flask.request.cookies`593attribute. Again this is a dictionary with all the cookies the client594transmits. If you want to use sessions, do not use the cookies directly595but instead use the :ref:`sessions` in Flask that add some security on top596of cookies for you.597598599Redirects and Errors600--------------------601602To redirect a user to somewhere else you can use the603:func:`~flask.redirect` function, to abort a request early with an error604code the :func:`~flask.abort` function. Here an example how this works::605606 from flask import abort, redirect, url_for607608 @app.route('/')609 def index():610 return redirect(url_for('login'))611612 @app.route('/login')613 def login():614 abort(401)615 this_is_never_executed()616617This is a rather pointless example because a user will be redirected from618the index to a page he cannot access (401 means access denied) but it619shows how that works.620621By default a black and white error page is shown for each error code. If622you want to customize the error page, you can use the623:meth:`~flask.Flask.errorhandler` decorator::624625 from flask import render_template626627 @app.errorhandler(404)628 def page_not_found(error):629 return render_template('page_not_found.html'), 404630631Note the ``404`` after the :func:`~flask.render_template` call. This632tells Flask that the status code of that page should be 404 which means633not found. By default 200 is assumed which translates to: all went well.634635.. _sessions:636637Sessions638--------639640Besides the request object there is also a second object called641:class:`~flask.session` that allows you to store information specific to a642user from one request to the next. This is implemented on top of cookies643for you and signs the cookies cryptographically. What this means is that644the user could look at the contents of your cookie but not modify it,645unless he knows the secret key used for signing.646647In order to use sessions you have to set a secret key. Here is how648sessions work::649Fixed a broken example in the docsArmin Ronacherbefore adoptione753222
line 650why, one step back650 from flask import Flask, session, redirect, url_for, escape, requestFix in docs for handle_exception: "A" before nouns pronounced with an initial consonant soundDag Odenhallbefore adoptioncc7876f
line 651why, one step back651Fixed a broken example in the docsArmin Ronacherbefore adoptione753222
lines 652–653why, one step back652 app = Flask(__name__)653Fix in docs for handle_exception: "A" before nouns pronounced with an initial consonant soundDag Odenhallbefore adoptioncc7876f
lines 654–675why, one step back654 @app.route('/')655 def index():656 if 'username' in session:657 return 'Logged in as %s' % escape(session['username'])658 return 'You are not logged in'659660 @app.route('/login', methods=['GET', 'POST'])661 def login():662 if request.method == 'POST':663 session['username'] = request.form['username']664 return redirect(url_for('index'))665 return '''666 <form action="" method="post">667 <p><input type=text name=username>668 <p><input type=submit value=Login>669 </form>670 '''671672 @app.route('/logout')673 def logout():674 # remove the username from the session if its there675 session.pop('username', None)Fixed a broken example in the docsArmin Ronacherbefore adoptione753222
line 676why, one step back676 return redirect(url_for('index'))Fix in docs for handle_exception: "A" before nouns pronounced with an initial consonant soundDag Odenhallbefore adoptioncc7876f
lines 677–737why, one step back677678 # set the secret key. keep this really secret:679 app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'680681The here mentioned :func:`~flask.escape` does escaping for you if you are682not using the template engine (like in this example).683684.. admonition:: How to generate good Secret Keys685686 The problem with random is that it's hard to judge what random is. And687 a secret key should be as random as possible. Your operating system688 has ways to generate pretty random stuff based on a cryptographic689 random generator which can be used to get such a key:690691 >>> import os692 >>> os.urandom(24)693 '\xfd{H\xe5<\x95\xf9\xe3\x96.5\xd1\x01O<!\xd5\xa2\xa0\x9fR"\xa1\xa8'694695 Just take that thing and copy/paste it into your code and you're done.696697Message Flashing698----------------699700Good applications and user interfaces are all about feedback. If the user701does not get enough feedback he will probably end up hating the702application. Flask provides a really simple way to give feedback to a703user with the flashing system. The flashing system basically makes it704possible to record a message at the end of a request and access it next705request and only next request. This is usually combined with a layout706template that does this.707708To flash a message use the :func:`~flask.flash` method, to get hold of the709messages you can use :func:`~flask.get_flashed_messages` which is also710available in the templates. Check out the :ref:`message-flashing-pattern`711for a full example.712713Logging714-------715716.. versionadded:: 0.3717718Sometimes you might be in the situation where you deal with data that719should be correct, but actually is not. For example you have some client720side code that sends an HTTP request to the server, and it's obviously721malformed. This might be caused by a user tempering with the data, or the722client code failed. Most the time, it's okay to reply with ``400 Bad723Request`` in that situation, but other times it is not and the code has to724continue working.725726Yet you want to log that something fishy happened. This is where loggers727come in handy. As of Flask 0.3 a logger is preconfigured for you to use.728729Here are some example log calls::730731 app.logger.debug('A value for debugging')732 app.logger.warning('A warning occurred (%d apples)', 42)733 app.logger.error('An error occurred')734735The attached :attr:`~flask.Flask.logger` is a standard logging736:class:`~logging.Logger`, so head over to the official stdlib737documentation for more information.Added middlewares to quickstart. This fixes #88Armin Ronacherbefore adoptiona3a72e2
lines 738–742why, one step back738739Hooking in WSGI Middlewares740---------------------------741742If you want to add a WSGI middleware to your application you can wrap theFixed a typo in quickstartArmin Ronacherbefore adoption3ebc97a
line 743why, one step back743internal WSGI application. For example if you want to use one of theAdded middlewares to quickstart. This fixes #88Armin Ronacherbefore adoptiona3a72e2
lines 744–748why, one step back744middlewares from the Werkzeug package to work around bugs in lighttpd, you745can do it like this::746747 from werkzeug.contrib.fixers import LighttpdCGIRootFix748 app.wsgi_app = LighttpdCGIRootFix(app.wsgi_app)