Reputation: 31
I'm writing a Flask web app, and I want to call a function from views.py when a user leaves one specific page (closes the page or goes to another page). How do I do this?
Upvotes: 3
Views: 5117
Reputation: 7289
You could use a websocket (i.e see https://flask-socketio.readthedocs.io/en/latest/#connection-events). You can register a disconnect handler function.
Upvotes: 2