Update plot in dash from REST API

Dash doesn’t currently have any ‘push’ functionality, meaning that external connections can’t push events to the renderer. So you should be thinking about Dash requesting information rather than automagically receiving information.

It sounds like the general pattern of a) having your JSON POST endpoint save your data somewhere and b) having your dash app read from that location, could be the way to go.

There’s lots of ways you can do this, so long as you avoid the trap of storing this data as global variables. Which one you choose depends on the needs of your app. if you only ever need to retrieve the last submitted data, you could just save it to disk and read that file in Dash. Or even save to a directory and have the Dash interface present to you a selection of files. If you need any more complexity to how results are retrieved, you’ll probably need to use a database to manage results. sqlite would be a could choice for this kind of thing.

1 Like