获取烧瓶请求中收到的数据

谁说我不能喝 提交于 2020-08-17 17:20:11

问题:

I want to be able to get the data sent to my Flask app. 我希望能够将数据发送到我的Flask应用。 I've tried accessing request.data but it is an empty string. 我尝试访问request.data但是它是一个空字符串。 How do you access request data? 您如何访问请求数据?

@app.route('/', methods=['GET', 'POST'])
def parse_request():
    data = request.data  # data is empty
    # need posted data here

The answer to this question led me to ask Get raw POST body in Python Flask regardless of Content-Type header next, which is about getting the raw data rather than the parsed data. 这个问题的答案使我提出了在Python Flask中获取原始POST正文的问题,而不管接下来的Content-Type标头如何 ,这都是关于获取原始数据而不是已解析数据的。


解决方案:

参考一: https://stackoom.com/question/hmVz/获取烧瓶请求中收到的数据
参考二: https://oldbug.net/q/hmVz/Get-the-data-received-in-a-Flask-request
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!