changeset 27:b411066b4929

example/persona.py
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 26 Dec 2013 22:43:24 -0800
parents feeb97e8c23c
children 0f57029d663d
files example/persona.py
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/example/persona.py	Thu Dec 26 21:18:15 2013 -0800
+++ b/example/persona.py	Thu Dec 26 22:43:24 2013 -0800
@@ -15,12 +15,14 @@
 page = os.path.join(here, 'persona.html')
 
 class PersonaTest(object):
-    def __init__(self, page):
-        self.page = page or globals()['page']
+    def __init__(self, page=page):
+        self.page = page
         assert os.path.exists(self.page), "File '%s' not found" % self.page
         self.page = open(self.page, 'r').read()
     def __call__(self, environ, start_response):
-        raise NotImplementedError
+        start_response("200 OK", [('Content-Type', 'text/html'),
+                                  ('Content-Length', str(len(self.page)))])
+        return [self.page]
 
 def main(args=sys.argv[1:]):
 
@@ -31,8 +33,10 @@
                       help="port to serve on")
     options, args = parser.parse_args(args)
 
+    app = PersonaTest()
+
     server = simple_server.make_server('127.0.0.1', options.port, app)
-    print 'server on http://localhost:8080'
+    print 'server on\nhttp://localhost:%d/' % options.port
     try:
         server.serve_forever()
     except KeyboardInterrupt: