Come una richiesta diventa una risposta
Segua il percorso completo da client a view e poi alla risposta.
Come una richiesta diventa una risposta è una lezione Flask Academy gratuita su CoddyKit. Questa è la lezione 2 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Flask Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Flask Academy include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
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. 🔁
Domande Frequenti
La lezione «Come una richiesta diventa una risposta» è gratuita?
Sì — il testo completo di «Come una richiesta diventa una risposta» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Flask Academy, passa a CoddyKit PRO. Il corso Flask Academy include 4 lezioni in totale.
Cosa imparerò in «Come una richiesta diventa una risposta»?
Segua il percorso completo da client a view e poi alla risposta. Eserciti Flask Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare Flask Academy?
Non è richiesta alcuna esperienza precedente. Flask Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 2 di 4.
Quanto tempo richiede la lezione «Come una richiesta diventa una risposta»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione Flask Academy?
Sì. Ogni lezione Flask Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Il decoratore @app.route
- Come una richiesta diventa una risposta
- Restituire stringhe, HTML e codici di stato
- Più route in una sola app