rewrote code to work as a flask app on heroku