python 中使用flask框架

在使用python开发中使用falsk框架,在ajax中使用data传递参数,
但是如果参数太多,会变得很麻烦。求解答如何在flask框架中接受
ajax的传递过去的参数,试过了一些flask方法,但是获取值为None
求详细解答,谢谢!求详细解答,谢谢!求详细解答,谢谢!图片说明图片说明

POST方法的数据存放在request.form里,可能你获取了request.args或request.data,一般是空的。

@app.route('/', methods=['GET', 'POST'])
def parse_request():
    data = request.form
    print(data)

直接把参数作为post的json数据发送过去,flask中直接收到数据后转换为json来处理

  • request.args: the key/value pairs in the URL query string
  • request.form: the key/value pairs in the body, as sent by a HTML POST form
  • request.files: the files in the body, which Flask keeps separate from form
  • request.values: combined args and form, preferring args if keys overlap