diff requestdumpster/dumpster.py @ 8:eb260393caef

this is about as far as I want to get without webob
author Jeff Hammel <k0scist@gmail.com>
date Wed, 16 Dec 2015 10:51:32 -0800
parents 83c51f45b82d
children db2ab581cedb
line wrap: on
line diff
--- a/requestdumpster/dumpster.py	Wed Dec 16 10:31:00 2015 -0800
+++ b/requestdumpster/dumpster.py	Wed Dec 16 10:51:32 2015 -0800
@@ -9,7 +9,7 @@
 import os
 import sys
 import time
-import wsgiref
+from wsgiref import simple_server
 
 # module globals
 __all__ = ['RequestDumpster']
@@ -25,6 +25,10 @@
     def __call__(self, environ, start_response):
         """WSGI"""
 
+        body = """{REQUEST_METHOD} {PATH_INFO} {SERVER_PROTOCOL}""".format(**environ)
+
+        start_response('200 OK', [('Content-Type', 'text/plain')])
+        return [body]
 
 def main(args=sys.argv[1:]):
     """CLI"""
@@ -45,7 +49,10 @@
     url = 'http://localhost:{port}/'.format(port=options.port)
 
     # serve some web
-    server = simple_server.make_server(host=host, port=int(port), app=app)
+    host = '127.0.0.1'
+    server = simple_server.make_server(host=host,
+                                       port=options.port,
+                                       app=app)
     print url
     try:
         server.serve_forever()