get request receiving flask, and the return json format

#启动实验 后台服务
(docker run -tdi  -p 51000:22  -p 51002:5000   --name csy5   --privileged=true registry.cn-hangzhou.aliyuncs.com/mkmk/flask:csy5  init)&&(docker exec -d csy5 /bin/bash -c "cd /home/c#sy5 && nohup python app.py  &")
@app.route('/api/login',methods=['GET'])
def login():
    usercount1,password1=request.args.get('usercount'),request.args.get('password')
    resinfo={'resinfo':connectdb.judge_login_info(usercount1,password1)}
    print(resinfo)
    return  json.dumps(resinfo,ensure_ascii=False)

request.args.get ( 'usercount')
both get information

return json.dumps (resinfo, ensure_ascii = False )
return json format data according to the dictionary
ensure_ascii = False, without this one, cause Chinese garbled

Published 72 original articles · won praise 1 · views 3441

Guess you like

Origin blog.csdn.net/qq_43373608/article/details/103437717