当前位置:网站首页>Blueprint class view method
Blueprint class view method
2022-07-27 08:33:00 【pink_ Pig___】
Blueprint method
- Create two py file ,app.py Document and user.py File write code
stay user.py Write the blueprint in the file
from flask import Blueprint
# Instantiate objects
user_bp = Blueprint('user_bp', __name__, url_prefix='/user')
@user_bp.route('/register')
def register():
return ' Registered users '
- stay app.py Registration blueprint
from flask import Flask
from user import user_bp
# Registered blueprint
app.register_blueprint(user_b)
if __name__ == '__main__':
app.run()
# route
# http://127.0.0.1:5000/user/register
Class view method
- stay user.py Write code in file
from flask import Flask
from flask_restful import Api, Resource
user_pb = Blueprint('user_pb', __name__, url_prefix='/user')
@user_bp.route('/register')
def register():
return ' Registered users '
# Instantiate a Api object ,Api Object is used to collect routes
api = Api(user_bp)
# Define a class , Inherited from Resource class , Disguise the current class as a view class
class Users(Resource):
def get(self):
return ' This is a class view get Method '
def post(self):
return ' Is a class view post Method this '
# The first parameter is the class object , The second is routing
api.add_resource(Users, '/users')
边栏推荐
- I drew a Gu ailing with characters!
- CMD command and NPM command
- Help send some recruitment. If you are interested, you can have a look
- arguments
- 第2章 前台数据展现
- Risk control and application of informatization project
- Hundreds of people participated. What are these people talking about in the opengauss open source community?
- Containerd failed to pull private database image (kubelet)
- All in one 1329 cells (breadth first search)
- MCDF top level verification scheme
猜你喜欢

Minio installation and use

OSI seven layer model and tcp/ip four layer (TCP and UDP) (notes)

IBM3650M4实体机安装VCenter7.0

Bandwidth and currency

vCenter7.0管理Esxi7.0主机
![[NPUCTF2020]ReadlezPHP 1](/img/d9/590446b45f917be3f077a9ea739c20.png)
[NPUCTF2020]ReadlezPHP 1

Background image related applications - full, adaptive

Oppo self-developed large-scale knowledge map and its application in digital intelligence engineering

永久设置source的方法

How to view instances of software objects in QSIM?
随机推荐
Download and usage of sequel Pro
Minio installation and use
CMD command and NPM command
Explain cache consistency and memory barrier
[MRCTF2020]Ezpop 1
Zhongang Mining: the new energy industry is developing rapidly, and fluorine chemical products have a strong momentum
永久设置source的方法
JS advanced knowledge - function
Using ecological power, opengauss breaks through the performance bottleneck
Implementation of adding function of background user management display
You may need an additional loader to handle the result of these loaders.
Interviewer: what is scaffolding? Why do you need scaffolding? What are the commonly used scaffolds?
1178 questions of Olympiad in informatics -- ranking of grades
Background coupon management
Block, there is a gap between the block elements in the row
Flask request data acquisition and response
好吃难吃饱七分为宜;好喝难喝醉三分为佳
Installation and use of beef XSS
Chapter 2 foreground data display
SSTI template injection