Skip to content

Instantly share code, notes, and snippets.

@messa
Created March 19, 2016 22:32
Show Gist options
  • Save messa/0f1aa1df06cb21cd8156 to your computer and use it in GitHub Desktop.
Save messa/0f1aa1df06cb21cd8156 to your computer and use it in GitHub Desktop.
Gunicorn Hello World example
class App:
def __call__(self, environ, start_response):
return self.dispatch(environ, start_response)
def dispatch(self, environ, start_response):
"""Simplest possible application object"""
data = b'Hello, World!\n'
status = '200 OK'
response_headers = [
('Content-type','text/plain'),
('Content-Length', str(len(data)))
]
start_response(status, response_headers)
return iter([data])
my_app = App()
run: venv/bin/gunicorn
venv/bin/gunicorn -b 127.0.0.1:9000 app:my_app
venv/bin/gunicorn:
test -d venv || pyvenv-3.4 venv
venv/bin/pip install -U pip
venv/bin/pip install gunicorn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment