SHARE
TWEET

Untitled

a guest Sep 16th, 2011 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from paste.httpserver import *
  2. from webob import *
  3. from webob.dec import *
  4.  
  5. from zipfile import ZipFile
  6. from tempfile import TemporaryFile
  7. from pprint import pformat
  8.  
  9. form = '''
  10. <form method=POST action=/ enctype="multipart/form-data">
  11. <input type=file name=file>
  12. <input type=submit>
  13. '''
  14.  
  15. @wsgify
  16. def test_app(req):
  17.     if req.method == 'GET':
  18.         return Response(form)
  19.     f = TemporaryFile()
  20.     z = ZipFile(f, 'w')
  21.     z.writestr('environ.txt', pformat(req.environ))
  22.     z.writestr('wsgi-input.data', req.body_file_raw.read())
  23.     z.close()
  24.     f.seek(0)
  25.     return Response(body_file=f, content_type='application/zip')
  26.  
  27. serve(test_app)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top