refactored run_flask.py