render_template() connects Flask code to a page template: pass a template filename and values, and the rendered content appears in the browser. section 10.0
A submitted order follows a small, friendly relay:
- Read the selected drink with request.form['drink']. section 10.0
- Return print.html while passing drink=drink. section 10.0
- Display the value with {{drink}} inside the template. section 10.0
Show the customer’s drink
Inside the order route, return render_template("print.html", drink=drink). In print.html, place {{drink}} where the selected drink should appear. section 10.0
@app.route('/order', methods=('GET', 'POST'))
def order():
if request.method == 'POST':
drink = request.form['drink']
print("Drink: ", drink)
return render_template("print.html", drink=drink) #1
return render_template("forms.html")
Browse the complete order route, including GET and POST handling and the value passed to print.html. section 10.0


