0PricingLogin
Flask Academy · Lesson

render_template and the templates Folder

Return an HTML file instead of a string.

From Strings to Pages

So far your routes returned plain strings. Real pages need HTML, and Flask gives you render_template to serve full HTML files cleanly.

What render_template Does

render_template finds an HTML file, runs it through the template engine, and returns the finished page as your response body.

from flask import render_template

@app.route('/')
def home():
    return render_template('index.html')

All lessons in this course

  1. render_template and the templates Folder
  2. Pass Data into a Template
  3. Jinja2 Loops and Conditionals
  4. Autoescaping and the safe Filter
← Back to Flask Academy