macOS ◆ xterm ◆ bash 167 views

$ mkdir python-hello-world $ cd python-hello-world/ $ pyvenv env $ . ./env/bin/activate $ pip install flask $ pip freeze > requirements.txt $ cat <<EOF > app.py

import os
from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
    return "Hello World!\n"

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=int(os.environ.get('PORT', 5001)))

$ cat <<EOF > Procfile web: python app.py $ cf push -m 128M -b python_buildpack python-hello-world $ curl http://python-hello-world.cfapps.io/