蓝图到底是什么?定义路由的时候路由在哪里?注册的时候发生了什么?钩子和错误处理器的范围有多大?这篇从 deferred_functions 开始逐项打印。
蓝图对象上记录的延迟函数 deferred_functions 个数: 1 | 类型: ['function']
注册前 app.url_map 的规则: [] | app.blueprints = {}
注册后 app.url_map 的规则: [('/ping', 'api.ping')] | app.blueprints = {'api': 'Blueprint'}上一篇:路由冲突如何解决;下一篇:Blueprint 的 URL 前缀。
AssertionError: The setup method 'route' can no longer be called on the blueprint 'api'. It has already been registered at least once, any changes will not be applied consistently.
请求 /shop/info 时: {'blueprint': 'shop', 'blueprints': ['shop'], 'endpoint': 'shop.info', 'rel': '/shop/info', 'abs': '/shop/info'} 规则: [('/p/c/x', 'parent.child.x')] | GET /p/c/x → child x
请求里 request.blueprints = ['parent.child', 'parent'] | request.blueprint = parent.child/b3/t → 回调 ['b3.before_request'] | 模板里 who = who=b3 /plain → 回调 [] | 模板里 who=(无) 蓝图的 errorhandler(404):GET /b3/nope → <!doctype html> <html lang=en> <title>404 Not Found</title> <h1>Not Found</h1> <p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p> (路由没匹配,不属于任何蓝图,用的是应用的默认 404)
[('/shop/', 'shop.home'), ('/shop/<int:i>', 'shop.item')]
shop home | item 3
蓝图对象的 root_path: <项目>/shop