# HG changeset patch # User Jeff Hammel # Date 1388126604 28800 # Node ID b411066b4929f6b83a41a8ec82ef9e525a58cc04 # Parent feeb97e8c23cc621dd616774de0edc94e4a312eb example/persona.py diff -r feeb97e8c23c -r b411066b4929 example/persona.py --- a/example/persona.py Thu Dec 26 21:18:15 2013 -0800 +++ b/example/persona.py Thu Dec 26 22:43:24 2013 -0800 @@ -15,12 +15,14 @@ page = os.path.join(here, 'persona.html') class PersonaTest(object): - def __init__(self, page): - self.page = page or globals()['page'] + def __init__(self, page=page): + self.page = 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 + start_response("200 OK", [('Content-Type', 'text/html'), + ('Content-Length', str(len(self.page)))]) + return [self.page] def main(args=sys.argv[1:]): @@ -31,8 +33,10 @@ help="port to serve on") options, args = parser.parse_args(args) + app = PersonaTest() + server = simple_server.make_server('127.0.0.1', options.port, app) - print 'server on http://localhost:8080' + print 'server on\nhttp://localhost:%d/' % options.port try: server.serve_forever() except KeyboardInterrupt: