当前位置:网站首页>【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()
边栏推荐
- 安装tldr
- For high performance, large scale model training, this combination "career"
- 795. 前缀和
- I've only known since Kiali that configuring Istio's traffic management is so easy
- One: OpenCV image reading and writing file help documentation
- stm32项目之SPI通信2.4G模块(NF2401L)
- 2022.08.03_Daily Question
- 对话庄表伟:开源第一课
- How to use the timetable applet
- 通俗易懂玩QT:QT程序发布打包
猜你喜欢

STM32H743IIT6 study notes 03 - using third-party components FreeRTOS

我和 TiDB 的故事 | 学tidb半年,社区治好了我的精神内耗

isn't it?Is there anyone who can't locate the slow query problem of MySQL online?
Shang Silicon Valley-JVM-Performance Monitoring and Tuning (P302~P381)

文盘Rust -- 配置文件解析

Go compilation principle series 9 (function inlining)

Detailed analysis of the three cluster strategies of Redis

尚硅谷-JVM-内存和垃圾回收篇(P1~P203)

Taizhou Yifeng Kress Servo Drive Commissioning Instructions
![[Supply Chain·Case] What did the top ten retailers in the world do under the influence of the epidemic?](/img/44/9ef9f86f8afb85f49aac1cce55723d.jpg)
[Supply Chain·Case] What did the top ten retailers in the world do under the influence of the epidemic?
随机推荐
ADC acquisition of CC2530
solaris-oralce rac installation
797. Difference
795. 前缀和
OGC WebGIS 常用服务标准(WMS/WMTS/TMS/WFS)速查
2022.08.01_Daily Question
Depth Map-Based Object Detection
hello world, hello Keke people
Common methods of Go language strings library
NFT card game system dapp develops NFT chain game technology
isn't it?Is there anyone who can't locate the slow query problem of MySQL online?
文盘Rust -- 配置文件解析
[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
STM32H743IIT6学习笔记03——使用第三方组件FreeRTOS
Simple clock animation
C语言例题-打印日历
Food and Beverage Industry B2B Mall System: Accelerate the digital transformation of the industry and improve the transaction efficiency of the B2B platform
796. 子矩阵的和
Digital-intelligent supply chain system in the household appliance industry: efficiently integrate the supply chain and enhance the core competitiveness of household appliance enterprises
What is a buffer (buffer) and what is a cache (cache)