1def __parse_post_body(environ, ignore_get=False):
2 post_data = {}
3
4 # accept post json
5 if environ["CONTENT_TYPE"].strip(';') == "application/json" and environ["REQUEST_METHOD"] == "POST":
6 storage = environ['wsgi.input'].read()
7 if storage:
8 return json.loads(storage)
9
10 storage = FieldStorage(environ['wsgi.input'], environ=environ, keep_blank_values=True)
11
12 # accept get querystring
13 if not ignore_get:
14 for k in storage.keys():
15 post_data[k] = storage.getvalue(k)
16
17 return post_data