Beispiel #1
0
 def handler(*args, **kwargs):
     body = cherrypy.request._json_inner_handler(*args, **kwargs)
     return json.dumps(body, indent=indent) if cherrypy.response.headers['content-type'] == content_type else body
Beispiel #2
0
def json_error(version, **body):
    "Transform errors into json format."
    tool = cherrypy.request.toolmaps['tools'].get('json_out', {})
    cherrypy.response.headers['content-type'] = tool.get('content_type', 'application/json')
    return json.dumps(body, indent=tool.get('indent'))