Mercurial > hg > bitsyauth
comparison example/persona.py @ 25:e5efb021a8e6
example/persona.py
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Thu, 26 Dec 2013 20:11:30 -0800 |
parents | bdb005ae848b |
children | feeb97e8c23c |
comparison
equal
deleted
inserted
replaced
24:bdb005ae848b | 25:e5efb021a8e6 |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | |
3 import optparse | |
4 import os | |
5 import sys | |
6 | 2 |
7 """ | 3 """ |
8 test Mozilla persona auth | 4 test Mozilla persona auth |
9 | 5 |
10 https://login.persona.org/about | 6 https://login.persona.org/about |
11 """ | 7 """ |
12 | 8 |
9 import optparse | |
10 import os | |
11 import sys | |
12 from wsgiref import simple_server | |
13 | |
13 here = os.path.dirname(os.path.realpath(__file__)) | 14 here = os.path.dirname(os.path.realpath(__file__)) |
14 page = os.path.join(here, 'persona.html') | 15 page = os.path.join(here, 'persona.html') |
16 | |
17 class PersonaTest(object): | |
18 def __init__(self, page): | |
19 self.page = page or globals()['page'] | |
20 assert os.path.exists(self.page) | |
15 | 21 |
16 def main(args=sys.argv[1:]): | 22 def main(args=sys.argv[1:]): |
17 | 23 |
18 usage = '%prog [options]' | 24 usage = '%prog [options]' |
19 parser = optparse.OptionParser(usage=usage, description=__doc__) | 25 parser = optparse.OptionParser(usage=usage, description=__doc__) |
20 parser.add_option('-p', '--port', dest='port', | 26 parser.add_option('-p', '--port', dest='port', |
21 type='int', default=8123, | 27 type='int', default=8123, |
22 help="port to serve on") | 28 help="port to serve on") |
23 options, args = parser.parse_args(args) | 29 options, args = parser.parse_args(args) |
24 | 30 |
25 | 31 server = simple_server.make_server('127.0.0.1', options.port, app) |
32 print 'server on http://localhost:8080' | |
33 try: | |
34 server.serve_forever() | |
35 except KeyboardInterrupt: | |
36 pass | |
26 | 37 |
27 if __name__ == '__main__': | 38 if __name__ == '__main__': |
28 main() | 39 main() |