I was trying some stuff with statemachine, but it seems to be overkill, so I'm going back to the basics and trying to use flask in a smarter way