Parsing Python HTML POST data from BaseHTTPServer

I am sending a couple of files from an HTML form to my BaseHTTPServer based server.

Inside my do_POST, I get a line from rfile.read (length) that looks like some kind of multi-page MIME line. Google does not help in how I can decode this into something useful.

The result is as follows:

-----------------------------122422713313797828591978698502

Content-Disposition: form-data; name="MAX_FILE_SIZE"



1000000

-----------------------------122422713313797828591978698502

Content-Disposition: form-data; name="and_title_input"

etc.

I tried email.parser

from email.parser import Parser 
p=Parser()
msg=p.parsestr(s)

but msg does not seem to bring me closer to my goal - it does not breed and does not contain a payload.

I came down to self-analysis of data, which, of course, is not a pythonic way of doing something!

Am I missing something obvious? Is Google letting me down? Can a stack overflow save a day?

+3

Source: https://habr.com/ru/post/1754388/


All Articles