当前位置:网站首页>First acquaintance with Flask
First acquaintance with Flask
2022-07-31 05:43:00 【The flowers are blooming in the south of the city^】
Flask Framework Components
Flask_sqlalchemy: A good combination of Flask and SQLAlchemy, such as ORM operations in django
flask_script: used to generate commands, use commands in the project root directory path; for example: python manage.py runserver
flask_migrate: used to implement database migration (depending on flask_script)
flask-session: session is placed in redis
blinker: signal - trigger signal. Mainly to allow developers to customize some behaviors during the flask request process
Briefly describe the Flask context management process
There are two contexts in Flask, **request context** and **application context**.
1. Request context: saves the data that the client and server interact with.
Application context: some configuration information saved during the running process of the flask program, such as program file name, database connection, user information, etc.
request and session belong to the request context object.
request: Encapsulates the content of the HTTP request, which is for the HTTP request.Example: user = request.args.get('user'), which gets the parameters of the get request.
Session: used to record the information in the request session, for user information.For example: session['name'] = user.id, user information can be recorded.You can also get user information through session.get('name')
current_app and g both belong to the application context object.
current_app: Indicates the program instance of the currently running program file.
g: The object used for temporary storage when processing requests, this variable will be reset for each request.For example: we can obtain some user information for temporary requests.
When calling app = Flask(_name_), the program application object app is created;
request When every http request occurs, the WSGI server calls Flask.call(); then the request object created inside Flask;
The life cycle of the app is longer than request and g. During the life of an app, multiple http requests may occur, so there will be multiple requests and g.
Finally, the view function is passed in, and the response object is generated by return, redirect or render_template and returned to the client.
边栏推荐
- gin框架学习-Casbin进阶之策略管理API使用方法
- gin框架学习-GORM框架进阶之CRUD接口(数据库增删改查操作)
- leetcode-每日一题873. 最长的斐波那契子序列的长度(哈希和二分)
- 剑指offer专项突击版 ---- 第 6 天
- Quickly master concurrent programming --- the basics
- C语言教程(三)-if和循环
- leetcode-每日一题1217. 玩筹码(贪心+位运算)
- Sword Point Offer Special Assault Edition ---- Day 1
- leetcode-每日一题565. 数组嵌套(标记图和并查集)
- 剑指offer基础版 ---- 第27天
猜你喜欢

leetcode-438. 找到字符串中所有字母异位词(滑动窗口)

leetcode-每日一题565. 数组嵌套(标记图和并查集)

The process and specific code of sending SMS verification code using flask framework

The interviewer asked me TCP three handshake and four wave, I really

账号或密码多次输入错误,进行账号封禁

“档次法”——用于物品体积分布不均匀的01背包问题的求解方法

leetcode-每日一题735. 行星碰撞(栈模拟)

gin框架学习-Casbin进阶之策略管理API使用方法

【数据库学习】Redis 解析器&&单线程&&模型

13 【代理配置 插槽】
随机推荐
docker安装postgresSQL和设置自定义数据目录
tf.keras.utils.get_file()
剑指offer专项突击版 ---第 5 天
12 【nextTick 过渡与动画】
[MQ I can speak for an hour]
Three handshakes and four waves
leetcode-2321. 拼接数组的最大分数(差分+枚举)
C语言实验三 选择结构程序设计
Flask-based three-party login process
代码执行漏洞
07 【内置指令 自定义指令】
Sword Point Offer Special Assault Edition ---- Day 1
Oracle数据库中的“limit”查询
数据库上机实验6 数据库完整性
uni-app进阶之样式框架/生产环境【day10】
实验8 DNS解析
利用phpstudy搭建DVWA
Object Detection Study Notes
The interviewer asked me how to divide the database and the table?Fortunately, I summed up a set of eight-part essays
The process and specific code of sending SMS verification code using flask framework