Created
October 14, 2015 10:19
-
-
Save codeachange/dbdbce33567229b56d29 to your computer and use it in GitHub Desktop.
测试用,把 request 里的各种变量格式化后返回
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
# 测试用,把 request 里的各种变量格式化后返回 | |
def show_request(): | |
request_dict = {} | |
request_dict['forms'] = {} | |
for item in request.forms: | |
request_dict['forms'][item] = request.forms.getall(item) | |
request_dict['query'] = {} | |
for item in request.forms: | |
request_dict['query'][item] = request.query.getall(item) | |
#The below does not work - multipart/form-data doesn't serialize in json | |
#request_dict['files'] = {} | |
#for item in request.files: | |
#request_dict['files'][item] = request.files.getall(item) | |
request_dict['GET'] = {} | |
for item in request.GET: | |
request_dict['GET'][item] = request.GET.getall(item) | |
request_dict['POST'] = {} | |
for item in request.POST: | |
request_dict['POST'][item] = request.POST.getall(item) | |
request_dict['params'] = {} | |
for item in request.params: | |
request_dict['params'][item] = request.params.getall(item) | |
request_dict['json'] = request.json | |
return json.dumps(request_dict, indent=3)+"\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment