How to update the different status continuously from a REST API with one callback

Hi Team,

I have scenario to implement in Dash APP. Where I have a REST API which shows a JOB status which will contains with three status [“Started”, “Inprogress”, “Completed”] will changes for every rest api call after sometime.

I need to show these status on Dash APP using one callback.
i.e, when I click a button, A callback has to go to server and start hitting the REST API for the status…

If the status is Started — I need to show/return the same status on Dash APP
in the same callback the Rest API needs hit again and get the status… If the status is InProgress, I need to show this status on Dash APP.

When the Job is completed, I finally needs to show Completed on Dash APP.

So, It is a continuous Rest API call to get the Status and show the same on Dash APP with a single callback.

Please help me to fix this requirement.

Thanks in advance.

@Emil

Hello @Sandeep,

You can use a background callback, this allows you to send a progress status back to the client.

Go to the section about the progress bar, you can actually send back anything you want about the progress using:

set_progress()# status update here. 

My guess is for the completed, you want it to stay up for like 3 seconds, you could delay for the last status of 3 seconds after the progress status update.

I would recommend creating a callback that gets the status from the API and updates the desired UI elements (i.e. targets them as Output). Then, to trigger the callback periodically (e.g. once per second), you can setup an Interval component (use this one as Input).

@Emil,

Could you please provide me with an Example code?