from flask import Flask,request,jsonify,make_response
app=Flask(__name__)
users_info={
'1801':['123456','zhangsan',9000],
'1802':['123456','lisi',9080],
'1803':['123456','wangwu',9009]
}
设置动态路由,返回json数据
@app.route("/users/<string:account>",methods=["GET"])
def get_user01(account):
if account in users_info:
info=users_info[account]
return jsonify({"code":200,"message":"success","data": {"name":info[1],"balance":info[-1]}})
else:
return jsonify({"code": 200,"message": "account does not exit"})