Jinja Templates in Flask

The Jinja templating engine is one of the key building blocks of a Flask application.

With them, you can:

  1. Use static HTML template files to decouple routes from HTML
  2. Separate HTML structure from content
  3. Use programming constructs -- variables, conditionals, and for loops to control shown content -- in your templates

A template file (containing variables and logic) is rendered into an output file (typically HTML).


from flask import render_template

def index():
    return render_template('index.html')