Basic use of Jinja templates

The first step to using Jinja templates is creating a directory in our application to contain our template files, so navigate to your headlines directory, and create a directory called templates. Unlike the previous steps, this name is expected by other parts of the application and is case sensitive, so take care while creating it. At the most basic level, a Jinja template can just be an HTML file, and we'll use the .html extension for all our Jinja templates. Create a new file in the templates directory called home.html. This will be the page that our users see when visiting our application, and will contain all the HTML that we previously had in a Python string.


We'll only be using Jinja to build HTML files in ...

Get Flask By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.