def on_post(self, request, response):
query = dict()
try:
raw_json = request.stream.read()
except Exception as e:
raise falcon.HTTPError(falcon.HTTP_400, 'Error', e.message)
try:
data = json.loads(raw_json, encoding='utf-8')
except ValueError:
raise falcon.HTTPError(falcon.HTTP_400, 'Malformed JSON')
if "id" not in data:
raise falcon.HTTPConflict('Task creation', "ID is not specified.")
if "type" not in data:
raise falcon.HTTPConflict('Task creation', "Type is not specified.")
transaction = self.client.push_task({ "task" : "vertex", "data" : data })
response.body = json.dumps({ "transaction" : transaction })
response.status = falcon.HTTP_202
评论列表
文章目录