

To set the parameters you run the set (for Windows) or export (for Linux) command. When you have one or two configuration parameters you want to set, using environment variables is the easiest configuration method. Configuration methodsįlask provides 4 main ways you can configure a flask application: environment variables, config attribute of the flask app instance, a CFG file and an object. The official flask documentation on this topic provides a nice list of all the built-in flask variables that can be configured to suit your needs. The table below gives a rundown of the various components:Ĭonfiguring a flask application is the process of specifying the value of key parameters used to control the behavior of the flask application instance and its extensions. You should create the following project structure for a project with two blueprints: |-application.py |-config.py |-.env |-.gitignore |-readme.md |-requirements.txt |-celery_worker.py |-Dockerfile |-docker-compose.yml |-pytest.ini |-env/ |-tests/ |-conftest.py |-test_main.py |-test_auth.py |-test_models.py |-app/ |-_init_.py |-models.py |-forms.py |-tasks.py |-static/ |-templates/ |-base.html |-400.html |-403.html |-404.html |-405.html |-500.html |-auth/ |-_init_.py |-views.py |-forms.py |-templates/auth |-register.html |-main/ |-_init_.py |-views.py |-forms.py |-templates/mai |-index.html You could also add a third blueprint, api, for handling programmatic access to the web application resources. The main blueprint handles the functionality and features unique to the application.

The auth blueprint handles all the functionality related to users- registration, login, logout, password reset and account confirmation. My personal approach is to use two blueprints, auth and main. You should think of a flask application structured using blueprints as several key pieces of functionality working together to deliver the complete web application.Ī flask application is made up of blueprints (Author’s own)īefore you start coding your project, it is a good idea to first give thought to what blueprints you can divide the application into. The _init_.py file is what distinguishes a package from a standard folder: if it is present in a folder then that folder is a package if it is not present then that folder is just a normal storage folder.Ī blueprint is a package that encapsulates one specific piece of functionality in your application. A package is a folder that contains one or more modules along with an _init_.py file. However, the commonly accepted pattern for large projects is to break your project into multiple packages using Flask Blueprints.Ī module is a single. If you are building a small project, there is no harm in having all of your code in a single module. You as a developer are given full autonomy to decide how to structure your web application. Project Structure: Flask Blueprints What are blueprints?įlask is a very flexible web development framework.
