Jinja2 Templates and Forms
Learn how to inject Python into HTML with templates and how to collect user data with forms.
StartKey Concepts
Review core concepts you need to learn to master this subject
Flask Templates
render_template
Function
Template Variables
Template Variable Filters
Template if
Statements
Template for
Loops
Template Inheritance
Flask Web Forms
Flask Templates
Flask Templates
Flask uses templates to expand the functionality of a web application while maintaining a simple and organized file structure. Templates are enabled using the Jinja2 template engine and allow data to be shared and processed before being turned in to content and sent back to the client.
What you'll create
Portfolio projects that showcase your new skills
How you'll master it
Stress-test your knowledge with quizzes that help commit syntax to memory
Flask Templates
Which directory does
render_template
look for template files?Flask Forms
Given the following 2 routes:
py @app.route("/items") def item_list(): return render_template("items.html") @app.route("/items/<int:id>) def get_item(id): return render_template("one_item.html", item_id=id)
Complete the code that setshref
to the URL string"/items/2"
.