bundling required python dependencies, to make it easier on Tails users
56
lib/werkzeug/testsuite/multipart/collect.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
#!/usr/bin/env python
|
||||
"""
|
||||
Hacky helper application to collect form data.
|
||||
"""
|
||||
from werkzeug.serving import run_simple
|
||||
from werkzeug.wrappers import Request, Response
|
||||
|
||||
|
||||
def copy_stream(request):
|
||||
from os import mkdir
|
||||
from time import time
|
||||
folder = 'request-%d' % time()
|
||||
mkdir(folder)
|
||||
environ = request.environ
|
||||
f = open(folder + '/request.txt', 'wb+')
|
||||
f.write(environ['wsgi.input'].read(int(environ['CONTENT_LENGTH'])))
|
||||
f.flush()
|
||||
f.seek(0)
|
||||
environ['wsgi.input'] = f
|
||||
request.stat_folder = folder
|
||||
|
||||
|
||||
def stats(request):
|
||||
copy_stream(request)
|
||||
f1 = request.files['file1']
|
||||
f2 = request.files['file2']
|
||||
text = request.form['text']
|
||||
f1.save(request.stat_folder + '/file1.bin')
|
||||
f2.save(request.stat_folder + '/file2.bin')
|
||||
open(request.stat_folder + '/text.txt', 'w').write(text.encode('utf-8'))
|
||||
return Response('Done.')
|
||||
|
||||
|
||||
def upload_file(request):
|
||||
return Response('''
|
||||
<h1>Upload File</h1>
|
||||
<form action="" method="post" enctype="multipart/form-data">
|
||||
<input type="file" name="file1"><br>
|
||||
<input type="file" name="file2"><br>
|
||||
<textarea name="text"></textarea><br>
|
||||
<input type="submit" value="Send">
|
||||
</form>
|
||||
''', mimetype='text/html')
|
||||
|
||||
|
||||
def application(environ, start_responseonse):
|
||||
request = Request(environ)
|
||||
if request.method == 'POST':
|
||||
response = stats(request)
|
||||
else:
|
||||
response = upload_file(request)
|
||||
return response(environ, start_responseonse)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run_simple('localhost', 5000, application, use_debugger=True)
|
BIN
lib/werkzeug/testsuite/multipart/firefox3-2png1txt/file1.png
Normal file
After Width: | Height: | Size: 523 B |
BIN
lib/werkzeug/testsuite/multipart/firefox3-2png1txt/file2.png
Normal file
After Width: | Height: | Size: 703 B |
BIN
lib/werkzeug/testsuite/multipart/firefox3-2png1txt/request.txt
Normal file
|
@ -0,0 +1 @@
|
|||
example text
|
BIN
lib/werkzeug/testsuite/multipart/firefox3-2pnglongtext/file1.png
Normal file
After Width: | Height: | Size: 781 B |
BIN
lib/werkzeug/testsuite/multipart/firefox3-2pnglongtext/file2.png
Normal file
After Width: | Height: | Size: 733 B |
|
@ -0,0 +1,3 @@
|
|||
--long text
|
||||
--with boundary
|
||||
--lookalikes--
|
BIN
lib/werkzeug/testsuite/multipart/ie6-2png1txt/file1.png
Normal file
After Width: | Height: | Size: 523 B |
BIN
lib/werkzeug/testsuite/multipart/ie6-2png1txt/file2.png
Normal file
After Width: | Height: | Size: 703 B |
BIN
lib/werkzeug/testsuite/multipart/ie6-2png1txt/request.txt
Normal file
1
lib/werkzeug/testsuite/multipart/ie6-2png1txt/text.txt
Normal file
|
@ -0,0 +1 @@
|
|||
ie6 sucks :-/
|
BIN
lib/werkzeug/testsuite/multipart/ie7_full_path_request.txt
Normal file
BIN
lib/werkzeug/testsuite/multipart/opera8-2png1txt/file1.png
Normal file
After Width: | Height: | Size: 582 B |
BIN
lib/werkzeug/testsuite/multipart/opera8-2png1txt/file2.png
Normal file
After Width: | Height: | Size: 733 B |
BIN
lib/werkzeug/testsuite/multipart/opera8-2png1txt/request.txt
Normal file
|
@ -0,0 +1 @@
|
|||
blafasel öäü
|
BIN
lib/werkzeug/testsuite/multipart/webkit3-2png1txt/file1.png
Normal file
After Width: | Height: | Size: 1,002 B |
BIN
lib/werkzeug/testsuite/multipart/webkit3-2png1txt/file2.png
Normal file
After Width: | Height: | Size: 952 B |
BIN
lib/werkzeug/testsuite/multipart/webkit3-2png1txt/request.txt
Normal file
|
@ -0,0 +1 @@
|
|||
this is another text with ümläüts
|