diff example/persona.py @ 31:6af220013aa1

example/persona.py setup.py
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 27 Dec 2013 12:13:18 -0800
parents 0bf52646061b
children 119cf9c81d3d
line wrap: on
line diff
--- a/example/persona.py	Fri Dec 27 11:24:23 2013 -0800
+++ b/example/persona.py	Fri Dec 27 12:13:18 2013 -0800
@@ -22,11 +22,18 @@
     def __call__(self, environ, start_response):
         method = environ['REQUEST_METHOD']
         if method == 'GET':
-            start_response("200 OK", [('Content-Type', 'text/html'),
-                                      ('Content-Length', str(len(self.page)))])
+            content_type = 'text/html'
             body = self.page
         elif method == 'POST':
-            body = '\n'.join([])
+            content_type = 'text/plain'
+            body = '\n'.join(['%s: %s' % (key, environ[key])
+                              for key in sorted(environ.keys())])
+            print body
+        else:
+            content_type = 'text/plain'
+            body = 'Try GET or POST to do something interesting (How did you get here?)'
+        start_response("200 OK", [('Content-Type', content_type),
+                                  ('Content-Length', str(len(body)))])
         return [body]
 
 def main(args=sys.argv[1:]):