view example/persona.py @ 26:feeb97e8c23c

example/persona.py
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 26 Dec 2013 21:18:15 -0800
parents e5efb021a8e6
children b411066b4929
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), "File '%s' not found" % self.page
        self.page = open(self.page, 'r').read()
    def __call__(self, environ, start_response):
        raise NotImplementedError

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