- remove_red_eye97 Views
- event6 Mar 2020
- access_time2 min read
In the last tutorial, we studied about the routers in Flask. If you are a new visitor, kindly check the Flask series and follow all the tutorials.
In this tutorial, we are going to learn to template in Flask and learn how to render HTML templates.
First, create a new folder in the project directory called templates. Create a new file in the templates folder naming “home.html”.
Copy/paste this simple code.
Now open app.py and add the following code.
app = Flask(__name__)
if __name__ == '__main__':
We are importing render_template function provided by the Flask and then rendering our HTML template in the home route.
Run the app using the command.
Now, navigate your browser to localhost:5000 to see the output.
Awesome! You have just rendered an HTML template in the Flask.
In the next tutorial, we will perform the dynamic rendering using Jinja templating engine.