'Python Dash - Execute code on app shutdown

I develop apps in R Shiny and Python Dash.

On my Shiny apps, I can exectute some code when the user closes the app with the following code in server.R :

  session$onSessionEnded(function() {
    print("end of session")
    # execute some code
  })

Is there a way to make something similar in Dash when the user closes the app on the browser ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source