Book Image

Flask Framework Cookbook

By : Shalabh Aggarwal
Book Image

Flask Framework Cookbook

By: Shalabh Aggarwal

Overview of this book

Table of Contents (19 chapters)
Flask Framework Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Bootstrap layout


Most of the applications in Flask follow a specific pattern to lay out templates. In this recipe, we will talk about the recommended way of structuring the layout of templates in a Flask application.

Getting ready

By default, Flask expects the 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 add a new folder named templates under my_app. The application structure will now look like the following lines of code:

flask_app/
    - run.py
    my_app/
        – __init__.py
        - hello/
            - __init__.py
            - views.py
        - templates...