# HG changeset patch # User Jeff Hammel # Date 1292348204 28800 # Node ID 52713d176ab909caf851dfd3e7919a9dd97562f5 # Parent 431bd76aabb72396de3caaa1adb979b34a429c69 add an example....not done yet diff -r 431bd76aabb7 -r 52713d176ab9 example/example.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/example.py Tue Dec 14 09:36:44 2010 -0800 @@ -0,0 +1,25 @@ +#!/usr/bin/env python + +def example_app(environ, start_response): + if environ['PATH_INFO'].strip('/') == 'authorization_required': + user = environ.get('REMOTE_USER') + if user: + start_response("200 OK", [('Content-Type', 'text/plain'), + ('Content-Length', str(len(user)))]) + return [user] + else: + text = '401 Unauthorized' + start_response("401 Unauthorized", [('Content-Type', 'text/plain'), + ('Content-Length', str(len(text)))]) + return [text] + text = """ + bet you can't go here! +""" + start_response("200 OK", [('Content-Type', 'text/html'), + ('Content-Length', str(len(text)))]) + return [text] + +if __name__ == '__main__': + from wsgiref import simple_server + server = simple_server.make_server('127.0.0.1', 12345, example_app) + server.serve_forever()