Flask is one of the most used Python web frameworks. Every request a Flask app serves passes through this method: it runs the app's before-request hooks, calls your view only if no hook already answered, hands any exception to the app's error handlers, and finishes the response.
What to look for
The one decision that matters: a before-request hook that gives back anything (a login redirect, say) means your view never runs.
How much Thunder could read
9 of 9 steps put into words.
Read by the current Thunder compiler when this page was built. Hand-checked against the code: accurate and useful: every sentence checked against the code is true.
››››
Flow: How does it go? One action or rule as a path: questions with Yes and No, repeats, the Stops, what happens if something goes wrong, and what always happens at the end.
Flask can
Full dispatch request
From codelines 867–883
Author's noteDispatches the request and on top of that performs request pre and postprocessing as well as HTTP exception catching and error handling.
You get backa Response
=Works out: Sets got first request to True
→Does: Tries the next steps and handles the errors named below
→Does: Calls send
=Works out: Works out rv from preprocess request
Is rv None?
Yes
=Works out: Works out rv from dispatch request
No ↓ continue
If Exception goes wrong
=Works out: Works out rv from handle user exception
The same reading as Thunder Text, built with this page
Full dispatch request (Flask)
Author's note: Dispatches the request and on top of that performs request pre and postprocessing as well as HTTP exception catching and error handling.
You get back: a Response
- Sets got first request to True (line 874)
- Tries the next steps and handles the errors named below (line 876)
- Calls send (line 877)
- Works out rv from preprocess request (line 878)
- Ask: Is rv None? (line 879)
Yes:
- Works out rv from dispatch request (line 880)
No: continue
If Exception goes wrong:
- Works out rv from handle user exception (line 882)
- Gives back the result of finalize request (line 883)
Copyright 2010 Pallets. Licensed under the BSD 3-Clause. The code is shown unmodified; the Thunder reading is ThunderLang's.
Full license text (LICENSE)
Copyright 2010 Pallets
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.