Flask Blueprints
When building a Flask application, soon, the need of sorting the code somehow arises.
Too many routes in the main file is not a solution in the mid term.
Instead, using Blueprints to modularize the application provides a great way to extend the application code.
Let’s use a simple application folder structure:
1 | └── app |
where the several endpoints are placed into the resources folder.
The code for the resource user.py
is quite simple:
1 | from flask import jsonify, Blueprint |
The main Flask application remains as follows:
1 | from flask import Flask |