renderers.py 文件源码

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

项目:plone.server 作者: plone 项目源码 文件源码
def guess_response(self, value):
        resp = value.response
        if isinstance(resp, dict):
            resp = aioResponse(body=bytes(json.dumps(resp, cls=PServerJSONEncoder), 'utf-8'))
            resp.headers['Content-Type'] = 'application/json'
        elif isinstance(resp, list):
            resp = aioResponse(body=bytes(json.dumps(resp, cls=PServerJSONEncoder), 'utf-8'))
            resp.headers['Content-Type'] = 'application/json'
        elif isinstance(resp, str):
            resp = aioResponse(body=bytes(resp, 'utf-8'))
            resp.headers['Content-Type'] = 'text/html'
        elif resp is None:
            # missing result...
            resp = aioResponse(body=b'{}')
            resp.headers['Content-Type'] = 'application/json'

        resp.headers.update(value.headers)
        if not resp.prepared:
            resp.set_status(value.status)
        return resp
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号