Mercurial > hg > relocator
diff relocator/sample.py @ 0:68bea9e91bd2
initial import of relocator
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sun, 01 May 2011 13:31:40 -0700 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/relocator/sample.py Sun May 01 13:31:40 2011 -0700 @@ -0,0 +1,19 @@ +#!/usr/bin/env python + +from relocator import Relocator +from webob import exc + +def sample_app(environ, start_response): + """sample app that does a redirect""" + response = exc.HTTPSeeOther(location='/foo/bar') + return response(environ, start_response) + +def sample_factory(baseurl='http://example.com/toolbox'): + """create a webob view and wrap it in the relocator""" + return Relocator(sample_app, baseurl) + +if __name__ == '__main__': + from wsgiref import simple_server + app = sample_factory() + server = simple_server.make_server(host='0.0.0.0', port=12345, app=app) + server.serve_forever()