Porting a php web app to python flask