- 这里没有对内容进行py文件分割, 可以自己根据框架自己放入对应位置
- 以下代码生成一个 /v1/myapp/test 的路由
from flask import Flask
app = Flask(__name__)
from flask import Blueprint
# 二级蓝图
myapp = Blueprint('v1/myapp', __name__)
@myapp.route("/test", methods=["GET"])
def test():
pass
from flask import Blueprint
class NestableBlueprint(Blueprint):
def register_blueprint(self, blueprint, **options):
def deferred(state):
url_prefix = (state.url_prefix or u"") + (options.get('url_prefix', blueprint.url_prefix) or u"")
if 'url_prefix' in options:
del options['url_prefix']
state.app.register_blueprint(blueprint, url_prefix=url_prefix, **options)
self.record(deferred)
# 一级蓝图
v1 = NestableBlueprint('v1', __name__, url_prefix='/v1')
v1.register_blueprint(myapp, url_prefix="/myapp")
app.register_blueprint(v1)