changeset 25:e5efb021a8e6

example/persona.py
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 26 Dec 2013 20:11:30 -0800
parents bdb005ae848b
children feeb97e8c23c
files example/persona.py
diffstat 1 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/example/persona.py
+++ b/example/persona.py
@@ -1,28 +1,39 @@
 #!/usr/bin/env python
 
-import optparse
-import os
-import sys
-
 """
 test Mozilla persona auth
 
 https://login.persona.org/about
 """
 
+import optparse
+import os
+import sys
+from wsgiref import simple_server
+
 here = os.path.dirname(os.path.realpath(__file__))
 page = os.path.join(here, 'persona.html')
 
+class PersonaTest(object):
+    def __init__(self, page):
+        self.page = page or globals()['page']
+        assert os.path.exists(self.page)
+
 def main(args=sys.argv[1:]):
 
     usage = '%prog [options]'
     parser = optparse.OptionParser(usage=usage, description=__doc__)
     parser.add_option('-p', '--port', dest='port',
                       type='int', default=8123,
                       help="port to serve on")
     options, args = parser.parse_args(args)
 
-    
+    server = simple_server.make_server('127.0.0.1', options.port, app)
+    print 'server on http://localhost:8080'
+    try:
+        server.serve_forever()
+    except KeyboardInterrupt:
+        pass
 
 if __name__ == '__main__':
     main()