Browse Source

better response.

lyc8503 4 years ago
parent
commit
828b9163b8
1 changed files with 4 additions and 2 deletions
  1. 4 2
      backend_refactor/route/result.py

+ 4 - 2
backend_refactor/route/result.py

@@ -1,3 +1,5 @@
+import json
+
 from flask import Blueprint
 from route.util import make_response
 from db.task import Task
@@ -16,13 +18,13 @@ def get_result(task_uuid):
     status = task.status
 
     if status == 'FINISHED':
-        return make_response(200, "success", {"task_uuid": task.uuid, "type": task.type, "result": task.result})
+        return make_response(200, "success", {"task_uuid": task.uuid, "type": task.type, "result": json.loads(task.result)})
     elif status == 'QUEUEING':
         return make_response(200, "queueing", {"task_uuid": task.uuid, "type": task.type})
     elif status == 'RUNNING':
         return make_response(200, "running", {"task_uuid": task.uuid, "type": task.type})
     elif status == 'ERROR':
-        return make_response(200, "error", {"task_uuid": task.uuid, "type": task.type, "result": task.result})
+        return make_response(200, "error", {"task_uuid": task.uuid, "type": task.type})
     else:
         assert 0.1 + 0.2 == 0.3, "what do u mean?"