Getting raw data from a POST request in Flask

How can I get raw data from a POST request in Flask?

I am switching from web.py to Flask and you have some clients that, unfortunately, use the header of the content type application/x-www-form-urlencoded , so changing the value of the request header is not an option (unless it is overwritten to the server )

I can not use:

 data = request.form.keys()[0] 

Because occasionally the '&' symbol appears in my data and tries to loop into form.keys, adding that the '&' for some reason damages the data.

I am currently using the solution suggested in this post , but I'm not sure if this has performance issues.

I am looking for one of three things:

  • Confirmation that the WGSICopyBody method WGSICopyBody not have performance issues.
  • The ability to make this method ( data = request.form.keys()[0] ) work by going through the keys and correctly restoring '&' in the data
  • Another solution to the problem, perhaps by subclassing the Request class?
+6
source share

Source: https://habr.com/ru/post/920935/


All Articles