How Do We Use HTML Templates?

Introduction

In this lesson, we will learn how to render static templates, instead of plain text, on the front-end using the Flask framework.

Static templates

Static templates are the HTML files which remain constant. In fact, the standard HTML files are static in nature. Whenever the same file is rendered, it shows the same output unless the file is updated.

In a real-world web application, we expect an HTML file to be returned and rendered on the browser screen from the view function instead of a String.

Note: We assume that you are already familiar with the basics of HTML and CSS in the context of all lessons of Flask you will be studying.

Rendering HTML templates

HTML can be rendered in Flask using the following two methods:

A String

We can use the HTML as a String in the view function.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy