当前位置:网站首页>The blueprint of flask complements openpyxl
The blueprint of flask complements openpyxl
2022-07-28 22:30:00 【5xp_ two thousand and one】
Because our current project development is a relatively time-consuming and energy-consuming project , If we take all Flask If all the request methods are written in the same file , It is very inconvenient for us to manage the code and add the function code later
The following example : We write multiple routes in one file , This makes code maintenance difficult .

As shown in the figure , If we write all the request methods under the same processing file , It makes our code look illogical , If we want to modify the code or add new code later , It would be embarrassing , I don't know how to do it , At this point, we need our so-called blueprint to solve this problem , If you've learned django Of programmers may have known django Medium app The role of the , you 're right ,django Medium app The main function of will be django The project is divided into individual app, And then put all the app Assign different processing functions , They are connected into a large by routing assignment django project , Actually Flask Blueprints and django Medium app The function is the same , Let's have a general understanding of Flask The blueprint of , The code is as follows
We first create a master routing profile manage.py, The main function of this file is to start the whole Flask frame ( project ), As shown in the figure

next , We are manage.py Create two files in the same directory as admin.py user.py, Let's take a look at the contents of the two files


These two files are equivalent to django Two of them app 了 , The difference is django The route assignment in is to pass large routes through include Assigned to app Of urls.py, and Flask It is to add blueprints to the master by means of blueprint registration app in ,user.py,admin.py The main task in is to create blueprints , Then you can add some routing configurations to the created blueprint , Then we can create the main routing file manage.py Register the blueprint we created with the master app It's in .

In this way, after we have configured it, we can realize our hierarchical routing management , So let's try that , Run the main program manage.py

We access the route we set in the browser


The route we requested is the same as the return value we set , In this way, we have roughly completed a Flask Registration of blueprints for , Realize the hierarchical management of file function .
Add

边栏推荐
- Alibaba cloud CDN practice
- 网易云信 2022Q2 产品补给站,快来获取你的产品补给计划吧!
- JS array merging, de duplication, dimensionality reduction (es6: extended operator, set)
- HCIP第七次实验
- Sword finger offer II 066. sum of words (medium prefix tree design string)
- 软考网络工程师
- hcip实验(12)
- Mysql内置函数
- ATT&CK初步了解
- Lotus 1.16.0 extend sector expiration time
猜你喜欢

Ordinary practice of JS DOM programming

Jmeter 安装第三方插件 Plugins Manager

Netease Yunxin 2022q2 product supply station, come and get your product supply plan!

Lin Xiaobin, head of Tencent cloud database, borrowed 100 million yuan to speculate in stocks? Insider: the amount is not true

HCIP第七次实验

flask之蓝图 补充openpyxl

MySQL built-in functions

hcip实验(14)

Which is the file transfer command in the basic services of the Internet

Bugku, Web: all filtered
随机推荐
Closure, prototype and original link
使用webWorker执行后台任务
75. Color classification (medium array double pointer sorting)
What does GPRS network mean
Common commands of NPM
[leetcode] maximum depth of binary tree
ATT&CK 威胁情报
Less than a year after its establishment! MIT derivative quantum computing company completed financing of US $9million
Sword finger offer II 066. sum of words (medium prefix tree design string)
HCIP(11)
Necessary for in-depth learning: split the data set, split the labels according to the split pictures, and check the interval of all marked labels
98. Verify binary search tree (medium binary search tree DFS)
HCIP(14)
容器化配置启动redis集群 单机6节点 3主3从
Ordinary practice of JS DOM programming
NPM switch Taobao source (NPM source)
Changes in the history of oscilloscope development
Day3 classification management of Ruiji takeout project
MOV格式是不是静态图像文件格式
Establishment of Ruiji takeout development environment