Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing a Flask blueprint so that it can be safely mounted more than once?

Tags:

python

flask

The Flask documentation says :

that you can register blueprints multiple times though not every blueprint might respond properly to that. In fact it depends on how the blueprint is implemented if it can be mounted more than once.

But I can't seem to find out what must be done to mount a blueprint safely more than once.

like image 723
mickey06 Avatar asked Dec 20 '25 02:12

mickey06


1 Answers

It's hard to answer a question like this, because it is so general.

First, your Blueprint needs to be implemented in a way that makes no assumptions about the state of the app object it will be registered with. Second, you'll want to use a configurable url scheme to prevent route conflicts.

There are far more nuanced components of this, but without seeing your specific code and problem it's about as specific as I feel I can get.

like image 187
apiguy Avatar answered Dec 22 '25 17:12

apiguy