https://medium.com/@mathur.danduprolu/improving-flask-performance-with-middleware-and-background-tasks-part-6-7-ce9425cbde31