rewrote app in flask