知识卡片
蓝图集中注册路由
Flask 蓝图将一组 URL 的路由与配置聚合,再注册到应用。flask-smorest 的蓝图在此基础上连接请求/响应模型与 API 文档能力。按业务边界组织蓝图,可让路由定义集中,同时保留应用入口统一装配各组端点。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
原书出处
参考来源
- 位置:《Microservice APIs》第 6 章《Building REST APIs with Python》(源文件:_epub-src/OEBPS/Text/06.htm)
- 结论依据:原文定义蓝图用于一组 URL 的配置,说明 flask-smorest 蓝图继承 Flask 蓝图并增强文档和载荷验证,随后展示注册到 API 对象的步骤。
- 原始内容:Flask blueprints allow you to provide specific configuration for a group of URLs. To implement the kitchen API endpoints, we’ll use the flask-smorest’s Blueprint class . Flask-smorest’s Blueprint is a subclass of Flask’s Blueprint , so it provides the functionality that comes with Flask blueprints, enhances it with additional functionality and configuration that generates API documentation, and supplies payload validation models