Flask Blueprint structure

Theo Bouwman

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.

jbasko

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Flask Session not persistant in blueprint

From Dev

Inject dependencies in Flask blueprint

From Dev

Overwrite route in flask blueprint

From Dev

Flask Blueprint 404

From Java

flask blueprint template folder

From Dev

Flask - Forms - Blueprint

From Dev

Flask blueprint and registering path

From Dev

Blueprint error in Flask: NameError: name of blueprint is not defined

From Dev

Calling method from Flask Blueprint

From Dev

Flask: get current blueprint webroot

From Dev

Flask Blueprint Subdomain Not Working GAE

From Dev

How to init restless as flask blueprint

From Dev

Running a Flask blueprint from the program

From Dev

Query while declaring Flask Blueprint

From Dev

Flask - A blueprint's name collision occurred

From Dev

Flask BluePrint route not working with multiple parameteres

From Dev

Flask python blueprint logic code separation

From Dev

Flask: Blueprint not showing custom error page

From Dev

Flask: Template in Blueprint Inherit from Template in App?

From Dev

Flask Blueprint pass object to another file

From Dev

How to pass arbitrary arguments to a flask blueprint?

From Dev

how do I redirect to the flask blueprint parent?

From Dev

Can't get flask blueprint to work

From Dev

Python flask blueprint registration route for different arguments

From Dev

Flask Blueprint can't find static folder

From Java

Flask blueprint static directory does not work?

From Dev

What does it mean to register a blueprint into the app in Flask?

From Java

In Flask: How to access app Logger within Blueprint

From Dev

Using route decorator in a Flask blueprint's submodule