Como uma solicitação se torna uma resposta
Acompanhe o percurso completo do cliente à visualização e à resposta.
Como uma solicitação se torna uma resposta é uma aula grátis de Flask Academy no CoddyKit. Esta é a aula 2 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Flask Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Flask Academy inclui 4 aulas no total.
Partes desta aula ainda não foram traduzidas e aparecem em inglês.
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. 🔁
Perguntas Frequentes
A aula “Como uma solicitação se torna uma resposta” é grátis?
Sim — o texto completo de “Como uma solicitação se torna uma resposta” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Flask Academy, atualize para CoddyKit PRO. O curso de Flask Academy inclui 4 aulas no total.
O que vou aprender em “Como uma solicitação se torna uma resposta”?
Acompanhe o percurso completo do cliente à visualização e à resposta. Você pratica Flask Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.
Preciso ter experiência prévia para começar Flask Academy?
Nenhuma experiência prévia é necessária. Flask Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 2 de 4.
Quanto tempo leva a aula “Como uma solicitação se torna uma resposta”?
A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.
Posso escrever e executar código nesta aula de Flask Academy?
Sim. Cada aula de Flask Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.
Todas as aulas deste curso
- O decorador @app.route
- Como uma solicitação se torna uma resposta
- Retorne strings, HTML e códigos de status
- Várias rotas em um aplicativo