I am using Blueprints to separate my api
, admin
and authentication
, but in my API I want to separate users
, groups
and files
for a better structure instead of just one routes
file.
So my question is: is it possible to create a blueprint inside a blueprint?
Or is there a better solution to accomplish my structure needs?
Thanks in advance.
You don't have to "nest" them to achieve what you want. You just need to create the Blueprint
instance in one module and then import that instance in the multiple route files that you have for that blueprint.
# api/blueprint.py
from flask import Blueprint
bp = Blueprint(__name__, __name__)
# api/users.py
from .blueprint import bp
@bp.route(...)
# api/groups.py
from .blueprint import bp
@bp.route(...)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments