Skip to content

HelloPython #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

29 changes: 14 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
Sample Python Web application
Cloud Foundry / Python / Flask Example
=============================

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 demonstrate the Python support on [Pivotal's Cloud Foundry](https://run.pivotal.io/).

Deploy to Cloud Foundry
Deploy Version 1 (ultra basic, easy to understand)
-----------------------
```script
cf push <YOUR_APP_NAME> -m 128M -b https://github.com/heroku/heroku-buildpack-python.git

```
cd version1
cf push <app_name>
```

Deploy Version 2 (cleaner, more idiomatic with manifests/templates, etc)
-------------------------------

```
or
```script
cf push <YOUR_APP_NAME> -m 128M -b https://github.com/joshuamckenty/heroku-buildpack-python.git
cd version2
cf push
```
or
```script
cf push <YOUR_APP_NAME> -m 128M -b https://github.com/ephoning/heroku-buildpack-python.git
````

Notes
-----
2014/02/18: The offical Heroku buildpack seems not to be working with Cloud Foundry.
12 changes: 0 additions & 12 deletions hello.py

This file was deleted.

1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

1 change: 0 additions & 1 deletion runtime.txt

This file was deleted.

1 change: 1 addition & 0 deletions version1/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: python hello-idiomatic.py
32 changes: 32 additions & 0 deletions version1/hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import os
import uuid
from flask import Flask


app = Flask(__name__)
my_uuid = str(uuid.uuid1())
BLUE = "#0099FF"
GREEN = "#33CC33"

COLOR = GREEN

@app.route('/')
def hello():


return """
<html>
<body bgcolor="{}">

<center><h1><font color="white">Hi, I'm GUID:<br/>
{}</br>


</center>

</body>
</html>
""".format(COLOR,my_uuid,)

if __name__ == "__main__":
app.run(debug=False,host='0.0.0.0', port=int(os.getenv('PORT', '5000')))
6 changes: 6 additions & 0 deletions version1/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Flask==0.10.1
Jinja2==2.7.2
MarkupSafe==0.19
Werkzeug==0.9.4
itsdangerous==0.24
wsgiref==0.1.2
21 changes: 21 additions & 0 deletions version2/hello-idiomatic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from __future__ import print_function
import os
import uuid
from flask import Flask, render_template
from cfenv import AppEnv


env = AppEnv()
app = Flask(__name__)
my_uuid = str(uuid.uuid1())
BLUE = "#0099FF"
GREEN = "#33CC33"

COLOR = GREEN

@app.route('/')
def hello():
return render_template("index.html",bgcolor=COLOR,guid=my_uuid)

if __name__ == "__main__":
app.run(debug=False,host='0.0.0.0', port=env.port)
8 changes: 8 additions & 0 deletions version2/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
applications:
- name: hello-python-idiomatic-${random-word}
memory: 128M
buildpack: python_buildpack
domain: cfapps.io
command: python hello-idiomatic.py
timeout: 20
7 changes: 7 additions & 0 deletions version2/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Flask==0.10.1
Jinja2==2.7.2
MarkupSafe==0.19
Werkzeug==0.9.4
itsdangerous==0.24
wsgiref==0.1.2
cfenv==0.4.0
11 changes: 11 additions & 0 deletions version2/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<html>
<body bgcolor="{{ bgcolor }}">

<center><h1><font color="white">Hi, I'm GUID:<br/>
{{ guid }}</br>


</center>

</body>
</html>