使用Pyramid和Cornice,我如何告诉Cornice返回XML响应而不是JSON?似乎默认情况下使用的是JSON,this article展示了如何在Cornice中添加一个新的text/plain渲染器。错误响应仍然包含JSON主体。
如何切换到XML?
发布于 2015-06-16 21:44:44
据我所知,返回XML数据有两种方式:
使用Mako呈现XML:
<?xml version="1.0" encoding="utf-8"?>
<information>
</information>设置响应内容类型:
request.response.content_type = "text/xml"
return {'data': 'something'}https://stackoverflow.com/questions/30868143
复制相似问题