---
title: Structure Your Project with Flask Blueprint - Best Software Development Team Extension Partner for Nordics
description: Flask is a lightweight WSGI web application framework based on Python. It is designed in such a way that it will only supply the core components of a web
---

[Blog - Trusted Team Extension Partner For Europe & USA](https://www.craftsmensoftware.com/blog)

# [Structure Your Project with Flask Blueprint - Best Software Development Team Extension Partner for Nordics](https://www.craftsmensoftware.com/blog/structure-your-project-with-flask-blueprint)

 Written by [Md. Nahidur Rahman](https://www.craftsmensoftware.com/blog/author/md-nahidur-rahman) | 18/04/2024

Flask is a lightweight WSGI web application framework based on Python. It is designed in such a way that it will only supply the core components of a web application and it lets the developer choose rest of the things. It leaves all the design and architecture level decisions to the developer. As a result it is very easy to get started start with Flask. But day by day when the application gets bigger and more complex, it become very tough to maintain the code base. To resolve this problem Flask comes with **Blueprint**. **Flask Blueprint** or **Blueprint** for short, is a way to organize the related code base between python modules or packages. In this article we will learn how to use Blueprint to structure a Flask project. At the beginning, lets first create a hello world application in Flask. Create a file ***app.py*** and put the following code in it.

```
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
    return 'Hello, World!'
if __name__ == '__main__':
    app.run(debug=True)
```

Copy

What we have done here is that, first we have created an Flask application object by passing the name of the application’s module or package. Then we define a function **hello\_world** and associates it with ***’/’*** url endpoint using route decorator of the **app** object. Now open up your terminal and write this command **python app.py** and hit enter. It will run your application on port 5000 of your machine. While the application is running, go to **http://localhost:5000** in your favorite browser and see that ***Hello, World!*** is printed on it. As your basic Flask application is up and running. Now create a new file **views.py** and write the following code in it.

```
from flask import Blueprint
index_blueprint = Blueprint('index_blueprint', __name__)
@index_blueprint.route('/index/')
def index():
    return 'This is flask blueprint example'
```

Copy

Here we have done the following things.

- We import **Blueprint** from **flask**.
- Created a Blueprint object and name it **index\_blueprint**.
- And associates our **index** function with ***/index/*** url endpoint using route decorator of **index\_blueprint**.

While creating the **index\_blueprint** object, first we have passed the name of the blueprint that will be used in Flask’s routing mechanism. And then we have passed **\_\_name\_\_** as the second argument which will be used by Flask to locate the Blueprint’s resources. Now that we have our blueprint object, we need to register it with **app** object. The following code base shows how to register **index\_blueprint** with **app** object in **app.py** file.

```
from views import index_blueprint
app = Flask(__name__)
app.register_blueprint(index_blueprint)
```

Copy

**app.register\_blueprint** is the method we used here to register the blueprint with the **app** object. As we have registered our blueprint with the application, it’s time to check if our blueprint is actually working. To check that open your terminal and run this command **python app.py**, then go to **http://localhost/index/** in your browser and see that ***This is flask blueprint example*** is printed.

We have successfully used **Flask Blueprint** in our project and we have structured our project in different python modules using the Blueprint. When the project will grow bigger and bigger that time we can adopt the following project structure to keep it more maintainable.

```
project_root/
— app.py
— app_module/
  — __init__.py
  — views.py
```

Copy

The complete code of this article can be found at [this repository](https://github.com/nahidsaikat/Structure-Your-Project-with-Flask-Blueprint.git).

[View full post](https://www.craftsmensoftware.com/blog/structure-your-project-with-flask-blueprint)

```json
{
  "@context" : "http://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Md. Nahidur Rahman"
  },
  "dateModified" : "2026-04-30T11:31:55.320Z",
  "datePublished" : "2024-04-18T19:00:00Z",
  "headline" : "Structure Your Project with Flask Blueprint",
  "image" : {
    "@type" : "ImageObject",
    "height" : 347,
    "url" : "https://144957314.fs1.hubspotusercontent-eu1.net/hubfs/144957314/Imported_Blog_Media/structure_your_project_with_flask_Blueprint.webp",
    "width" : 618
  },
  "mainEntityOfPage" : "https://www.craftsmensoftware.com/blog/structure-your-project-with-flask-blueprint",
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "height" : 60,
      "url" : "/hs/hsstatic/content_shared_assets/static-1.4092/img/default-amp-logo.png",
      "width" : 60
    },
    "name" : "Blog"
  }
}
```