How to handle file uploads with http.server

Neil Blue Neil.Blue at
Thu Mar 11 11:30:24 CET 2010


I have a basic http.server instance running (class
HTTPHandler(http.server.BaseHTTPRequestHandler), with python 3.1, and I
would like to upload files with multipart forms.

def do_POST(self):
	ctype, pdict = cgi.parse_header(self.headers['Content-Type'])
	if ctype=='multipart/form-data':
		query=cgi.parse_multipart(self.rfile, pdict)

However the file never seems to finish being parsed. There are no errors,
but the call hangs at: query=cgi.parse_multipart(self.rfile, pdict)

Please can anyone offer some insight into this or somewhere else I may find
some more information.



The information contained in this message is likely to be confidential.  It is intended only for the person named above.  Any dissemination, distribution, copying, disclosure or use of this message or its contents unless authorised by BioWisdom Ltd is strictly prohibited. Any views or opinions expressed within this e-mail are those of the author and do not necessarily represent those of BioWisdom Ltd. If you have received this message in error, please immediately notify us and delete it.  Thank you.  Registered Office: BioWisdom Ltd, Harston Mill, Harston, Cambridge, CB22 7GG.  Registered in England: (GB) 3861669.  VAT registered: (GB) 750899881.  Tel: +44 (0)1223 874800, Fax: +44 (0) 1223 874801, 


More information about the Python-list mailing list