Implementing an active window detection module with Flask and JavaScript. If the user moves away from his/her tab or window, an alert would be raised on the client side and a log would be made on the server side.
To run this just type python main.py
in the terminal. Click on the link shown in the terminal. A browser window must open. Now try opening another tab or window. You should see that a new log has been created.