Skip to content

Commit

Permalink
feat(api): respond w/ task.status
Browse files Browse the repository at this point in the history
instead of custom
  • Loading branch information
matthiasschaub committed Oct 16, 2023
1 parent fb66d6b commit 6383fba
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions sketch_map_tool/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ def status(uuid: str, type_: REQUEST_TYPES) -> Response:
if task.ready():
if task.successful(): # SUCCESS
http_status = 200
status = "SUCCESSFUL"
href = "/api/download/" + uuid + "/" + type_
elif task.failed(): # REJECTED, REVOKED, FAILURE
try:
Expand All @@ -173,19 +172,16 @@ def status(uuid: str, type_: REQUEST_TYPES) -> Response:
# The request was well-formed but was unable to be followed due
# to semantic errors.
http_status = 422 # Unprocessable Entity
status = "FAILED"
error = str(err)
except (Exception) as err:
http_status = 500 # Internal Server Error
status = "FAILED"
error = str(err)
else: # PENDING, RETRY, RECEIVED, STARTED
else: # PENDING, RETRY, STARTED
# Accepted for processing, but has not been completed
http_status = 202 # Accepted
status = "PROCESSING"
body_raw = {
"id": uuid,
"status": status,
"status": task.status,
"type": type_,
"href": href,
"error": error,
Expand Down

0 comments on commit 6383fba

Please sign in to comment.