Nested Blueprints in Flask?

后端 未结 3 1134
囚心锁ツ
囚心锁ツ 2020-12-09 17:54

I\'m still new to Flask, so there may be an obvious way to accomplish this, but I haven\'t been able to figure it out so far from the documentation. My app is divided into s

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-09 18:23

    Unfortunately, nested blueprints are not a current feature in Flask. You'll have to do it manually. You could probably code something that works for your specific case, but a general solution has not been added to Flask. There has been some discussion on the issue tracker:

    • https://github.com/mitsuhiko/flask/issues/593
    • https://github.com/mitsuhiko/flask/issues/1548
    • https://github.com/pallets/flask/issues/3215

    Adding nestable blueprints into Flask is not as trivial as automatically appending a prefix to routes. There are many other features of blueprints that need to be considered when nesting that make a general implementation significantly more complicated. The reason this has not been implemented yet is that no one in the community has had a great enough need for it that wasn't solved by a quick workaround vs contributing a general implementation.

提交回复
热议问题