Created
March 19, 2016 22:32
-
-
Save messa/0f1aa1df06cb21cd8156 to your computer and use it in GitHub Desktop.
Gunicorn Hello World example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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