liveBook · Manning

Request message

As explained in A Pythonic Adventure: From Python basics to a working web app

The POST method is an HTTP request method for submitting data to a web server for processing.

HTTP POST sends information to a web server for processing. In a Flask drink-order form, clicking Submit sends the selected drink instead of merely requesting a page. section 10.0

A simple POST flow looks like this:

  • Set the HTML form's method to post and its action to the server route. section 10.0
  • Register the Flask route for both GET and POST requests. section 10.0
  • Check request.method, read submitted values through request.form, and render a response. section 10.0

A drink-order form

A form posts to /order with a named drink field. Flask reads request.form['drink'], prints the selected value, and can render a thank-you page displaying it. section 10.0

Listing 10.2 The updated form with a variable and the action target
<html>
<body>
<form action="/order" method="post">
    <select name="drink">     </select>
    <input type="submit" value="Submit">           #1
      <option value="">- Choose drink -</option>   #2
      <option value="coffee">Coffee</option>       #3
      <option value="decaf">Decaf</option>         #3
 
</form>
</body>
</html>

Inspect the form markup that assigns the /order target, post method, drink field name, and selectable values. section 10.0

How A Pythonic Adventure: From Python basics to a working web app covers it

How deep it goes
Explains form configuration, route handling, request parsing, and response rendering, but stops short of broader HTTP internals.
Examples
Demonstrates a drink-order form that submits coffee or decaf and displays the selected order.
What it assumes
Assumes basic HTML forms and Flask routing while teaching the GET-versus-POST distinction incrementally.
What you can do after
Apply it via Flask to accept submitted form values and render a response containing them.
How it connects
Connects POST with HTTP GET, HTML forms, Flask routes, and request.form.

Also explained in

Compare how 14 books explain request message →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of A Pythonic Adventure: From Python basics to a working web app. The section links point to the parts of the book it draws on.