How a Request Becomes a Response
Walk the client to view to response round trip.
How a Request Becomes a Response is a free Flask Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Flask Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
The Round Trip
Every page view is a round trip: the browser sends a request, your server does work, and a response travels back. Let us trace that journey.
It Starts with a Request
A user clicks a link, and the browser sends an HTTP request. It carries the method, the URL path, and some headers describing the client.
Flask Matches the URL
Flask reads the path and finds the matching route. If no route matches, you get a 404 before any view function ever runs.
Your View Function Runs
Once matched, Flask calls your view function. This is where your code runs: read input, do logic, and decide what to send back.
@app.route("/time")
def time():
return "It is now"The Request Object
Inside the view, the request object holds everything the client sent. You import it from Flask to read details about the incoming call.
from flask import requestBuilding the Body
Your function returns a value, and that value becomes the response body. It can be text, HTML, or JSON depending on what you build.
The Response Object
Flask wraps your return value in a response object. That object bundles the body together with a status code and headers.
Status Codes Travel Back
Every response carries a status code. A 200 means success, while a 404 or 500 signals that something went wrong along the way.
Headers Describe the Reply
Response headers describe the body, like its content type and length. The browser reads them to know how to render what you sent.
The Browser Renders It
Finally the browser receives the response, reads the headers, and paints the body on screen. The round trip is complete.
One Request, One Response
The rule is simple: each request gets exactly one response. Your view runs, returns once, and Flask ships that single reply back.
Quick Check
Trace the request cycle in your head, then answer.
Recap
You traced the cycle: request in, route match, view runs, response out. Knowing this flow makes every Flask bug far easier to find. 🔁
Frequently asked questions
Is the “How a Request Becomes a Response” lesson free?
Yes — the full text of “How a Request Becomes a Response” is free to read here on the web, and the Flask Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Flask Academy course, upgrade to CoddyKit PRO.
What will I learn in “How a Request Becomes a Response”?
Walk the client to view to response round trip. You practise Flask Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Flask Academy?
No prior experience is required. Flask Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “How a Request Becomes a Response” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Flask Academy lesson?
Yes. Every Flask Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- The @app.route Decorator
- How a Request Becomes a Response
- Return Strings, HTML, and Status Codes
- Multiple Routes in One App