Bootstrapping the standard layout
Most of the applications in Flask follow a specific pattern of laying out templates. In this recipe, we will implement the recommended way of structuring the layout of templates in a Flask application.
Getting ready
By default, Flask expects templates to be placed inside a folder named templates
at the application root level. If this folder is present, then Flask will automatically read the contents by making the contents of this folder available for use with the render_template()
method, which we will use extensively throughout this book.
How to do it...
Let’s demonstrate this with a small application. This application is very similar to the one we developed in Chapter 1, Flask Configurations.
The first thing to do is to add a new folder named templates
under my_app
. The application structure should look like the following directory structure:
flask_app/ run.py my_app/ ...