view 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
line wrap: on
line source

#!/usr/bin/env python

"""
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()