Template

An HTML file with placeholders that a web framework fills in with data before sending it to the browser.

A template keeps your HTML in its own file with placeholders for the changing parts, so markup stays separate from Python logic. Flask uses the Jinja template engine: {{ name }} drops in a value and {% for item in items %} repeats a block.

render_template("index.html", name="Ada") loads the file from the templates/ folder and fills in the values you pass. Jinja auto-escapes them, so user text can't inject HTML.

Example
<h1>Hello, {{ name }}!</h1>
<ul>
  {% for note in notes %}
    <li>{{ note }}</li>
  {% endfor %}
</ul>

Where this shows up in real Python

Templates generate HTML pages with data filled in — the list of notes, the logged-in user’s name — without pasting HTML into your Python.

Commonly used Template tools

  • {{ value }} — drop a value into the page
  • {% for x in items %} — repeat markup for each item
  • {% if user %} — show markup conditionally
  • url_for('static', filename=...) — build links safely