def handler(request): msg = str(request.exception.message) log.info("xyz_handler (%s): %s" % (status, str(msg))) # request.response.status = status # request.response.content_type = "application/json" body = status_body(success=False, message=msg, to_json=True) rc = Response(body) rc.status = status rc.content_type = "application/json" return rc
def handler(request): msg = str(request.exception.message) log.info("xyz_handler (%s): %s" % (status, str(msg))) # request.response.status = status # request.response.content_type = "application/json" body = status_body( status="error", message=msg, ) rc = Response(body) rc.status = status rc.content_type = "application/json" return rc
def get_response(self, filename, content_type, data): """Prepare the response.""" response = Response() header_list = [ ('Content-Disposition', 'attachment; filename={filename}'.format( filename=filename )), ('Pragma', 'no-cache'), ('Expires', 'Fri, 29 Mar 2012 17:30:00 GMT'), ] response.status_int = 200 response.charset = 'utf-8' response.content_type = content_type response.text = data response.headerlist = header_list return response