Checking if a flask server is busy or idle
You can save the current datetime in a variable everytime a request is made via the @app.after_request annotation.
Then you need a routine to periodically check if the time difference between now and the saved timestamp is greater than 5 miutes. If so then run your task.
For executing your check every 5 minutes you may need some kind of scheduler which will be started with your application.
I want my flask server to do a certain task when its idle for some time lets say 5 mins, i.e after 5 mins it will do another job. For this i need something to check if a server is busy or idle. How can I achieve this?