develop.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:jatumba-backend 作者: YetAnotherTeam 项目源码 文件源码
def process_response(request, response):
        if request.GET.get('debug') == '':
            if response['Content-Type'] == 'application/octet-stream':
                new_content = ('<html><body>Binary Data, Length: {}</body></html>'
                               .format(len(response.content)))
                response = HttpResponse(new_content)
            elif response['Content-Type'] != 'text/html':
                content = response.content
                try:
                    json_ = json.loads(content)
                    content = json.dumps(json_, sort_keys=True, indent=2)
                except ValueError:
                    pass
                response = HttpResponse('<html><body><pre>{}</pre></body></html>'.format(content))

        return response
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号