diff options
Diffstat (limited to 'upload.py')
-rwxr-xr-x | upload.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/upload.py b/upload.py new file mode 100755 index 0000000..d81a8f0 --- /dev/null +++ b/upload.py @@ -0,0 +1,22 @@ +#!/usr/bin/python3 + +import python-multipart +import sys +import os + +fields = {} +files = {} +def on_field(field): + fields[field.field_name] = field.value +def on_file(file): + files[file.field_name] = {'name': file.file_name, 'file_object': file.file_object} + +with open ("multipart", mode='rb') as file: + form = file.read() + +multipart_headers = {'Content-Type': os.environ['CONTENT_TYPE']} +multipart_headers['Content-Length'] = os.environ['CONTENT_LENGTH'] +multipart.parse_form(multipart_headers, form, on_field, on_file) + +print(fields) +print(files) |