From f8eb92fbaa1fad7b08eb7744f9c300eaf043ef21 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 15 Oct 2011 10:32:38 -0400 Subject: [PATCH] Runner --- httpbin/runner.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 httpbin/runner.py diff --git a/httpbin/runner.py b/httpbin/runner.py new file mode 100755 index 0000000..5dd4bf5 --- /dev/null +++ b/httpbin/runner.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +""" +httpbin.runner +~~~~~~~~~~~~~~ + +This module serves as a command-line runner for httpbin, powered by +gunicorn. + +""" + +import sys + +from gevent.wsgi import WSGIServer +from httpbin import app + + +def main(): + try: + port = int(sys.argv[1]) + except (KeyError, ValueError, IndexError): + port = 5000 + + print 'Starting httpbin on port {0}'.format(port) + http_server = WSGIServer(('', port), app) + http_server.serve_forever() + +if __name__ == '__main__': + main() \ No newline at end of file