flask post接口开发代码编写完后,点击运行,始终提示TypeError: issubclass() arg 1 must be a class。
来源:4-3 Flask开发Post请求
慕圣1031945
2021-06-27
flask post接口开发代码编写完后,点击运行,始终提示TypeError: issubclass() arg 1 must be a class。
#coding=utf-8
from flask import Flask
from flask import request
import json
app=Flask(name)
@app.route(’/’)
def home():
data=json.dumps({
‘username’:‘mukewang’,
‘password’:‘12222’
})
return data
@app.route(‘passport/user/login’,methods=[‘GET’])
def Login():
username=request.args.get(“username”)
passeord=request.args.get(“password”)
if username and passeord:
data=json.dumps({
‘username’:username,
‘password’:passeord,
‘code’:‘200’,
‘message’:‘登录成功’,
‘info’:‘www.baidu.com’,
})
else:
data=json.dumps({
‘message’:‘请传递参数’
})
return data
@app.route(’/passport/user/post_login’,methods=[‘POST’])
def post_login():
request_method=request.method
if request_method==‘POST’:
request.form.get(‘username’)
request.form.get(‘password’)
data = json.dumps({
“username”: username,
“password”: password,
“code”: “200”,
“message”: “登陆成功”,
“info”: “www.Imooc.com”
})
else:
data = json.dumps({
“message”: “请求不合法”
})
#https://www.imooc.com/passport/user/login
if name==“main”:
app.run()
1回答
-
Mushishi
2021-06-27
额。@app.route(‘passport/user/login’,methods=[‘GET’])如果调用这个接口 仔细仔细 仔细。是不是少个/
00
相似问题