当前位置:网站首页>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

边栏推荐
- How to realize dynamic route switching and route caching in vuejs
- MySQL built-in functions
- SSH password free login
- tutorial/detailed_workflow.ipynb 量化金融Qlib库
- Static details of static members
- PaddleNLP基于ERNIR3.0文本分类:WOS数据集为例(层次分类)
- If you want to grow rapidly, you must first experience a major blow!
- HCIP(10)
- HCIP(14)
- [LiteratureReview]Object Detection and Mapping with Bounding Box Constraints
猜你喜欢
随机推荐
Ruiji takeout project - development of business development function Day2
Jianzhi offer II 062. implement prefix tree (medium design dictionary tree prefix tree string)
Netease Yunxin 2022q2 product supply station, come and get your product supply plan!
Sword finger offer II 063. replacement word (medium prefix tree string)
Sword finger offer II 057. the difference between the value and the subscript is within the given range (medium array bucket sort sliding window TreeSet)
Kali source solution software cannot be installed correctly
Sword finger offer II 053. Medium order successor in binary search tree (medium binary search tree DFS)
HCIP(10)
Remember the first line segment tree (corresponding to Luogu 3372)
Ultra detailed visual studio 2019 running littlevgl (lvgl) simulator
Use REM to make the font size adaptive to the screen
tutorial/detailed_ workflow. Ipynb quantitative finance qlib Library
ECMASript 5/6 笔记
HCIP(11)
Closure, prototype and original link
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
MySQL installation and configuration (super detailed, simple and practical)
CDN工作原理
SQL注入 Less42(POST型堆叠注入)
Establishment of Ruiji takeout development environment









