How to handle file uploads with http.server

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Mar 17 03:07:42 CET 2010


En Thu, 11 Mar 2010 07:30:24 -0300, Neil Blue <Neil.Blue at biowisdom.com>  
escribió:

> 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':
> 		print('parsing...')
> 		query=cgi.parse_multipart(self.rfile, pdict)
> 		print(query)
>
> 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)

This may be related to this bug:

http://bugs.python.org/issue8077

reported last week by Mitchell L. Model in this thread:

http://groups.google.com/group/comp.lang.python/t/8a7752bd79d5f5d6/

-- 
Gabriel Genellina




More information about the Python-list mailing list