关于python:如何获取在flask请求中接收的数据

How to get data received in Flask request

我想能够将数据发送到我的烧瓶应用程序。我试过访问request.data,但它是一个空字符串。如何访问请求数据?

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

这个问题的答案导致我在python flask中询问get raw post body,而不管接下来的内容类型是header,这是关于获取原始数据,而不是解析的数据。


(P)The docs describing the attributes available on the request.In most common cases EDOCX1 original 0 will be empty because it's used a s a fallback:(p)布尔奇1

  • EDOCX1:The key/value pairs in the URL query string
  • EDOCX1 2 enic:The key/value pairs in the body,from a html post form,or Javascript request that isn't json enceded
  • EDOCX1 3:The files in the body,which flask keeps separate from EDOCX1 original 4.HTML Forms must use EDOCX1 penographic 5 common or files will not be uploaded.
  • EDOCX1(英文)6:Combined EDOCX1(英文)7

(P)所有这些都是字母10You can access values using:(p)

  • EDOCX1语言:如果你知道关键的成功,使用索引
  • EDOCX1 12:使用EDOCX1,如果关键可能不存在
  • EDOCX1 14:Use EDOCX1 English 15 if the key is sent multiple times and you want a list of values.EDOCX1 13,只有第一个值。