I have a small Flask application in which I can detect if the client closed the connection to the server by using a generator streaming data continuously back to the client.