<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: Times New Roman; font-size: 12pt; color: #000000'>Dear python documentation maintainer,<br><br>I would like to submit a small text to the cgi module documentation to help other users use this module with BaseHTTPServer.HTTPServer. The current documentation (http://docs.python.org/library/cgi.html) shortly describes the usage of this module as a CGI under Apache. It does not covers at all the usage of cgi with BaseHTTPServer module. I've passed about an hour reading cgi.py sources to make it work, so I would like to share my knowledge with others.<br><br>Be so kind to include (mangled by you) the following text:<br>---------------------------------<br>Running with no parameters FieldStorage will read sys.stdin and use os.environ as environment variable. To use this module with BaseHTTPServer you must initialize FieldStorage with the rfile coming from WebHandler, pass headers as is and construct your ow environ to inform FieldStorage about the method used and the query string. Example for do_POST() function:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; form = cgi.FieldStorage(fp=self.rfile, headers=self.headers.dict, environ={"REQUEST_METHOD": "POST", "QUERY_STRING": self.path}) <br>See "print cgi.FieldStorage.__doc__" for more information on FieldStorage() parameters.<br><br>To upload files use enctype="multipart/form-data". For example:<br>&lt;form method="post" action="/my/url/to/python/script" enctype="multipart/form-data"&gt;<br>&lt;input type="file" name="filename"/&gt;<br>&lt;input type="hidden" name="additional params" value="123"/&gt;<br>&lt;input type="submit"/&gt;<br>&lt;/form&gt;<br>---------------------------------<br><br>Thank you for your great work!<br><br>Sincerely yours,<br>Poltorak Sergeui<br></div></body></html>