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	Thu Dec 26 20:06:49 2013 -0800
+++ b/example/persona.py	Thu Dec 26 20:11:30 2013 -0800
@@ -1,18 +1,24 @@
 #!/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]'
@@ -22,7 +28,12 @@
                       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()