E
import cgi
import io
body="""-----------------------------33331565381703838529424543671
....
"""
stream = io.BytesIO(body.encode())
params = {'boundary':b'---------------------------33331565381703838529424543671'}
# boundary брать из хидера, на два минуса меньше чем в теле.
cgi.parse_multipart(stream, params)
Exit{
"weblink_2_title":[""],
"real_name":[""],
"personaName":["name"],
"city":[""],
"state":[""],
"weblink_2_url":[""],
"weblink_1_title":[""],
"country":["RU"],
"weblink_1_url":[""],
"type":[
"profileSave",
"profileSave"
],
"weblink_3_title":[""],
"summary":["dsgsdfg"],
"json":["1"],
"weblink_3_url":[""],
"customURL":["url"],
"sessionID":[
"596a2f350ffccdcab68e5408",
"596a2f350ffccdcab68e6308"
]
}
Loss the sequence of answers... It's better for a consistent reading. https://docs.python.org/3/library/cgi.html#cgi.FieldStorage.getlist directly, as is done https://github.com/python/cpython/blob/b745a6143ae79efe00aa46affe5ea31a06b0b532/Lib/cgi.py#L184 No last team.headers = cgi.Message()
h.set_type('multipart/form-data; boundary=---------------------------33331565381703838529424543671')
fs=cgi.FieldStorage(stream, keep_blank_values=True, headers=headers, environ={'REQUEST_METHOD': 'POST'})
All fields with which to work https://ru.stackoverflow.com/questions/1234354/%D0%9A%D0%B0%D0%BA-%D1%81-%D0%BF%D0%BE%D0%BC%D0%BE%D1%89%D1%8C%D1%8E-post-%D0%B7%D0%B0%D0%BF%D1%80%D0%BE%D1%81%D0%B0-%D1%87%D0%B5%D1%80%D0%B5%D0%B7-requests-%D0%BF%D0%B5%D1%80%D0%B5%D0%B4%D0%B0%D1%82%D1%8C-multipart-form-data-%D1%82%D0%B0%D0%BA-%D1%87%D1%82%D0%BE%D0%B1 received sofiles = [(field.name,(field.filename,field.value)) for field in fs.value]
Reply to this question:dict(files)