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













