Checking if a user disconnects using Flask
Basically you can't tell that the user has left your site on the server-side. The common way to do what you want to achieve is to use a time limit after the last known request as a cutoff between the online/offline states. 
To make this more accurate you can have a script on the client-side that does regular AJAX polling, if you must consider that a user is online long after their last request while your site is still open in a tab. If you must check that the user has the tab active, make that request conditional on recent mouse or keyboard events.
I am trying to check if a user disconnects from my site, how would I go about doing this?
I am doing this in order to check if a user is "online" or not.