From bde094e42b3c49fdee8299010f869590acfc38a1 Mon Sep 17 00:00:00 2001 From: Matt Cowger Date: Mon, 14 Apr 2014 15:49:22 -0700 Subject: [PATCH 1/7] Basic --- hello.py | 8 ++++++-- requirements.txt | 7 ++++++- runtime.txt | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/hello.py b/hello.py index a492455..67930df 100644 --- a/hello.py +++ b/hello.py @@ -1,12 +1,16 @@ import os +import pprint +import logging from flask import Flask app = Flask(__name__) +logging.basicConfig(level=logging.DEBUG) + @app.route('/') def hello(): - return 'Hello World!' + return 'Hello World!\n' port = os.getenv('VCAP_APP_PORT', '5000') if __name__ == "__main__": - app.run(host='0.0.0.0', port=int(port)) \ No newline at end of file + app.run(host='0.0.0.0', port=int(port)) diff --git a/requirements.txt b/requirements.txt index 56eeb0c..3ec68a0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,6 @@ -Flask==0.10.1 \ No newline at end of file +Flask==0.10.1 +Jinja2==2.7.2 +MarkupSafe==0.19 +Werkzeug==0.9.4 +itsdangerous==0.24 +wsgiref==0.1.2 diff --git a/runtime.txt b/runtime.txt index 549b28a..dd6a7de 100644 --- a/runtime.txt +++ b/runtime.txt @@ -1 +1 @@ -python-2.6.5 +python-2.7.5 From 3ea42e9836d54a85ddaa9454d38fec6b2700a384 Mon Sep 17 00:00:00 2001 From: Matt Cowger Date: Tue, 6 Jan 2015 13:56:33 -0800 Subject: [PATCH 2/7] Updates --- hello.py | 28 +++++++++++++++++++++------- runtime.txt | 1 - 2 files changed, 21 insertions(+), 8 deletions(-) delete mode 100644 runtime.txt diff --git a/hello.py b/hello.py index 67930df..6327952 100644 --- a/hello.py +++ b/hello.py @@ -1,16 +1,30 @@ import os -import pprint -import logging +import uuid from flask import Flask - app = Flask(__name__) +my_uuid = str(uuid.uuid1()) +BLUE = "#0099FF" +GREEN = "#33CC33" + + + +COLOR = GREEN -logging.basicConfig(level=logging.DEBUG) @app.route('/') def hello(): - return 'Hello World!\n' + + return """ + + + +

Hi, I'm GUID:
+ {} +

+ + + + """.format(COLOR,my_uuid) -port = os.getenv('VCAP_APP_PORT', '5000') if __name__ == "__main__": - app.run(host='0.0.0.0', port=int(port)) + app.run(host='0.0.0.0', port=int(os.getenv('VCAP_APP_PORT', '5000'))) diff --git a/runtime.txt b/runtime.txt deleted file mode 100644 index dd6a7de..0000000 --- a/runtime.txt +++ /dev/null @@ -1 +0,0 @@ -python-2.7.5 From 8f02c009178066b45b207872bb83e0952dfc0a47 Mon Sep 17 00:00:00 2001 From: Matt Cowger Date: Mon, 13 Apr 2015 08:00:42 -0700 Subject: [PATCH 3/7] Add ignore file --- .gitignore | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7053ad5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,64 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*.pyc + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +.DS_Store + +.idea/ +private_config.cfg +private_config_new.cfg +config.json +*.pyc \ No newline at end of file From 5055d0227b21c742386b8fc2249d3bb6630174e7 Mon Sep 17 00:00:00 2001 From: Matt Cowger Date: Mon, 13 Apr 2015 08:16:34 -0700 Subject: [PATCH 4/7] Replaced procfile with manifest --- Procfile | 1 - manifest.yml | 9 +++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) delete mode 100644 Procfile create mode 100644 manifest.yml diff --git a/Procfile b/Procfile deleted file mode 100644 index 29e49ad..0000000 --- a/Procfile +++ /dev/null @@ -1 +0,0 @@ -web: python hello.py \ No newline at end of file diff --git a/manifest.yml b/manifest.yml new file mode 100644 index 0000000..2f4e4e1 --- /dev/null +++ b/manifest.yml @@ -0,0 +1,9 @@ +--- +applications: +- name: python-hello-mcowger + memory: 128M + no-route: false + host: python-hello-mcowger + instances: 1 + buildpack: python_buildpack + command: python hello.py From 9b31808a4205d1ac76ea8d5708a9bb45ddcb259f Mon Sep 17 00:00:00 2001 From: Matt Cowger Date: Tue, 14 Apr 2015 21:26:07 -0700 Subject: [PATCH 5/7] Go back to a procfile, and add directions for a BG deployment. --- Procfile | 1 + blue-green-deploy.sh | 0 hello.py | 7 ++----- manifest.yml | 9 --------- 4 files changed, 3 insertions(+), 14 deletions(-) create mode 100644 Procfile create mode 100644 blue-green-deploy.sh delete mode 100644 manifest.yml diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..8741ed9 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: python hello.py diff --git a/blue-green-deploy.sh b/blue-green-deploy.sh new file mode 100644 index 0000000..e69de29 diff --git a/hello.py b/hello.py index 6327952..df1e51e 100644 --- a/hello.py +++ b/hello.py @@ -6,14 +6,11 @@ BLUE = "#0099FF" GREEN = "#33CC33" - - -COLOR = GREEN - +COLOR = BLUE @app.route('/') def hello(): - + return """ diff --git a/manifest.yml b/manifest.yml deleted file mode 100644 index 2f4e4e1..0000000 --- a/manifest.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -applications: -- name: python-hello-mcowger - memory: 128M - no-route: false - host: python-hello-mcowger - instances: 1 - buildpack: python_buildpack - command: python hello.py From e056935262abd4413ba61a997c1d1312a8c79307 Mon Sep 17 00:00:00 2001 From: Matt Cowger Date: Wed, 10 Jun 2015 11:40:21 -0700 Subject: [PATCH 6/7] remove reference to heroku BP --- README.md | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 79e38c2..6783008 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,18 @@ Sample Python Web application -============================= - -The sample is using [Flask microframework](http://flask.pocoo.org/) and is intented to test the Python support on [Pivotal's Cloud Foundry](https://run.pivotal.io/). +==``=========================== +The`` sample is using [Flask microframework](http://flask.pocoo.org/) and is intented to test the Python support on [Pivotal's Cloud Foundry](https://run.pivotal.io/). +````` Deploy to Cloud Foundry ----------------------- ```script -cf push -m 128M -b https://github.com/heroku/heroku-buildpack-python.git +cf push -m 128M ``` or ```script -cf push -m 128M -b https://github.com/joshuamckenty/heroku-buildpack-python.git +cf push -m 128M ``` or ```script -cf push -m 128M -b https://github.com/ephoning/heroku-buildpack-python.git +cf push -m 128M ```` - -Notes ------ -2014/02/18: The offical Heroku buildpack seems not to be working with Cloud Foundry. From e60c51c97c15296adf91cbac540dd493cc2ee9ba Mon Sep 17 00:00:00 2001 From: sdcloudy Date: Wed, 15 Jul 2015 16:48:49 +0200 Subject: [PATCH 7/7] updated code with steteful counter --- hello.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/hello.py b/hello.py index df1e51e..ca7fa78 100644 --- a/hello.py +++ b/hello.py @@ -5,23 +5,27 @@ my_uuid = str(uuid.uuid1()) BLUE = "#0099FF" GREEN = "#33CC33" - +counter = 0 COLOR = BLUE @app.route('/') def hello(): - + global counter + counter = counter + 1 return """ -

Hi, I'm GUID:
+

Hi, I'm GUID: {} +


+

Hits: + {} +


- """.format(COLOR,my_uuid) - + """.format(COLOR,my_uuid,counter) if __name__ == "__main__": app.run(host='0.0.0.0', port=int(os.getenv('VCAP_APP_PORT', '5000')))