从Python中的POST请求检索json数据

时间:2020-08-12 01:06:12

标签: python json post request

嗨,我正在尝试用Python检索POST数据(在json中),我可以在GET请求中完成它,就像这样:

@app.route("/getmsg", methods=['GET'])
def getmsg():
    user = request.args.get('user')

但是当我在Json的POST请求上使用request.forms.get('user')时(例如{'user':'abcd'}),它说请求失败

有人可以告诉我如何正确地获取json数据吗?非常感谢。

0 个答案:

没有答案