from flask import Flask
import os

example_app = Flask(__name__)


@example_app.route('/')
def hello_world():
    return 'Hello Fellows June 2020.  Great to see you.  This is cool'


if __name__ == '__main__':
    # Heroku provides environment variable 'PORT' that should be listened on by Flask
    port = os.environ.get('PORT')

    if port:
        # 'PORT' variable exists - running on Heroku, listen on external IP and on given by Heroku port
        example_app.run(host='0.0.0.0', port=int(port))
    else:
        # 'PORT' variable doesn't exist, running not on Heroku, presumabely running locally, run with default
        #   values for Flask (listening only on localhost on default Flask port)
        example_app.run()
