Want more features on Pastebin? Sign Up, it's FREE!
Guest

punosqnp/wsgi_redirect_test.py

By: a guest on Aug 21st, 2010  |  syntax: Python  |  size: 0.65 KB  |  views: 40  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/python
  2.  
  3. from wsgiref.simple_server import make_server
  4.  
  5. def app(environ, start_response):
  6.         if environ['PATH_INFO'] == '/':
  7.                 start_response('302 Found', {
  8.                         'Location': '/foo%2Fbar/',
  9.                         'Content-Type': 'text/plain'
  10.                 }.items())
  11.                 return ['Redirecting to /foo%2Fbar/']
  12.         else:
  13.                 start_response('200 OK', {
  14.                         'Content-Type': 'text/plain'
  15.                 }.items())
  16.                 return ('{0} = {1}\n'.format(k, environ[k]) for k in sorted(environ))
  17.  
  18. httpd = make_server('', 8080, app)
  19. httpd.serve_forever()
clone this paste RAW Paste Data