python - How to get the request body bytes in Flask? -
the request's content-type
application/json
, want request body bytes. flask auto convert data json
. how request body?
you can non-form-related data calling request.get_data()
can parsed form data accessing request.form
, request.files
.
however, order in access these 2 change returned get_data
. if call first, contain full request body, including raw form data. if call second, typically empty, , form
populated. if want consistent behavior, call request.get_data(parse_form_data=true)
.
you can body parsed json using request.get_json()
, not happen automatically question suggests.
see docs on dealing request data more information.
Comments
Post a Comment