How to use 'flask get post data' in Python

Every line of 'flask get post data' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
9def getPostData():
10 #print(request.content_type)
11 data = {}
12 if (request.content_type.startswith('application/json')):
13 data = request.get_data()
14 return json.loads(data.decode("utf-8"))
15 elif(request.content_type.startswith("application/x-www-form-urlencoded")):
16 #print(1)
17 #print(urllib.parse.parse_qs(request.get_data().decode("utf-8")))
18 return parse_qs_plus(urllib.parse.parse_qs(request.get_data().decode("utf-8")))
19 else:
20 for key, value in request.form.items():
21 if key.endswith('[]'):
22 data[key[:-2]] = request.form.getlist(key)
23 else:
24 data[key] = value
25 return data

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

8def get_request_data():
9 return request.values.to_dict()

Related snippets