当前位置:网站首页>【Flask框架】三. Flask框架之蓝图的使用
【Flask框架】三. Flask框架之蓝图的使用
2022-08-05 12:21:00 【零碎@流年絮语】
三. Flask框架之蓝图的使用
蓝图创建
引入Blueprint
使用Blueprint()函数
代码如下
from flask import Blueprint
bp=Blueprint('user',__name__,url_prefix='/user')
@bp.route('/list')
def user():
return "user_list"
注册蓝图
在主程序中,通过app.register_blueprint()方法将这个蓝图注册进url映射中。
from flask import Flask
from apps import user
from apps import course
from apps import book
app = Flask(__name__)
app.register_blueprint(user.bp)
app.register_blueprint(course.bp)
app.register_blueprint(book.bp)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run()
边栏推荐
- Translation of "Grandmaster level in StarCraft II using multi-agent reinforcement learning"
- 789. Range of Numbers
- CC2530 realizes key interrupt
- MySQL check constraint
- sync-diff-inspector 使用实践
- C language classic examples - find the largest number in a series of numbers
- wallys/QCA9882/2×2 MIMO 802.11ac Mini PCIe Wi-Fi Module,
- MySQL之InnoDB线程模型
- Shang Silicon Valley-JVM-Performance Monitoring and Tuning (P302~P381)
- install tldr
猜你喜欢

家用电器行业数智化供应链系统:高效整合供应链,提升家电企业核心竞争力

微信开发者工具更换默认用户存储目录方法,将C盘数据User Data迁移到D盘

Monthly observation of Internet medical field in June 2022

Translation of "Grandmaster level in StarCraft II using multi-agent reinforcement learning"

MySQL之InnoDB线程模型

C language classic examples - find the largest number in a series of numbers

C语言例题-打印日历

NFT card game system dapp develops NFT chain game technology

今日开幕:LiveVideoStackCon 2022 音视频技术大会 上海站

NFT卡牌游戏系统dapp开发NFT链游技术
随机推荐
2022.08.03_每日一题
797. 差分
shell脚本,帮你提升摸鱼时间!
CC2530 realizes key interrupt
COSCon'22城市/学校/机构出品人征集令
尚硅谷-JVM-性能监控与调优篇(P302~P381)
wallys/QCA9882/2×2 MIMO 802.11ac Mini PCIe Wi-Fi Module,
[Share] Code programming habits: In the case of a multi-parameter method, the method needs to be sorted out - that is, the method with the most parameters is the main implementation
Sentinel introduction and use
Three.js 点击模型,高亮发光模型外轮廓
[供应链·案例篇]疫情影响下的全球十大零售商都做了些什么
Weak network test (1)
Shang Silicon Valley-JUC
自从用了 Kiali 以后才知道,配置 Istio 的 流量管理 是如此容易
Grid Infrastructure Installation Fails with Error
KVM虚拟化技术的-NUMA技术和应用
stm32项目之SPI通信2.4G模块(NF2401L)
798. Difference Matrix
软件设计七大原则之开闭原则(Open-Closed Principle, OCP)
790. 数的三次方根