Reputation: 670
I have made an API which generates 3d Models. Sometimes this can take a long time (>5 min). When it succeeds it returns the 3d Model in text form with statuscode 200. When failing I return the errorcode with statuscode 400.
Is there any way / mechanism to return a progress of processes? how could I do this? and how would Browsers read this?
Cheers and thanks!
Upvotes: 0
Views: 375
Reputation: 94
You can use next logic for this:
/generateModel
to generate model;operation_id
;/getStatus
with gained operation_id
;{ status: 0, progress: 0.02 }
.
Possible statuses:0
- still generating with progress (0.00
-0.99
)({ status: 0, progress: 0.02 }
);200
- done ({ status: 1 }
);other numbers
- error ({ status: 500, message: "Internal error" }
);done
status, client requests model /getModel
;error
status, it will be displayed.Upvotes: 1