def _output(self, data): """ JSON encode the response and set the appropriate headers """ body = json.dumps(data, default=json_encoder) http.header('Content-Type', 'application/json') http.header('Content-Length', len(body)) return body
def created(self, location, data): """ Return a created response. @type location: str @param location: URL of the created resource @type data: mapping type @param data: data to be returned in the body of the response @return: JSON encoded response """ http.status_created() http.header('Location', location) return self._output(data)