Integrating HTML Pages with Flask

PURPOSE

Understanding how to Render HTML Pages on a Flask based Web App

The Author assumes that you have read this blog [01] or have basic understanding of Flask, and HTML.

Step 1: Creating a templates directory, where your HTML files will be placed

Create a templates\ directory in your Project Root.

Step 2: Let's write a simple HTML Page

In your index.html present in your templates directory, add the following code:

Step 3: Let's render the HTML Page just created through Flask

If you followed the previous tutorial, your app.py file looks something like this:

Modify the file to:

Run the app.py file:

  • That's about it, just visit localhost:5000 on your browser, and say hello to the first of many pages you will serve using this technique.

Next Blog: How to render Dynamic Data to your webpage

Thank the author. Fork this blog.


Tagged in flask