result.py 894 B

1234567891011121314151617181920212223
  1. from operator import imod
  2. from flask import Blueprint
  3. from route.util import make_response
  4. from db.task import Task
  5. bp = Blueprint("result", __name__, url_prefix='/')
  6. @bp.route("/result/<task_uuid>", methods=["GET"])
  7. def get_result(task_uuid):
  8. task = Task.query.get(task_uuid)
  9. status = task.status
  10. if status == 'FINISHED':
  11. return make_response(200, "success", {"task_uuid": task.uuid, "type": task.type, "result": task.result})
  12. elif status == 'QUEUEING':
  13. return make_response(200, "queueing", {"task_uuid": task.uuid, "type": task.type})
  14. elif status == 'RUNNING':
  15. return make_response(200, "running", {"task_uuid": task.uuid, "type": task.type})
  16. elif status == 'ERROR':
  17. return make_response(200, "error", {"task_uuid": task.uuid, "type": task.type, "result": task.result})
  18. else:
  19. assert 0.1 + 0.2 == 0.3, "what do u mean?"