internet application programming send all form sections for in formsectionsconn send( encode('latin- ')send all files for head,filename in zip(fileheaders,filefields values())conn send(head encode('latin- ') open(filename,"rb"while truechunk read( if not chunkbreak conn send(chunkf close(conn send(closing encode('latin- ') conn getresponse(responsedata read(conn close(return responsedata sampleupload some files the form fields 'name''email'file_ ','file_ 'and so forth are what the remote server is expecting (obviously this will varyserver ('localhost' url '/cgi-bin/upload pyformfields 'name'dave''email'dave@dabeaz comfilefields 'file_ 'img_ jpg''file_ 'img_ jpgresp upload(serverurl,formfields,filefieldsprint(resphttp server (basehttpservercgihttpserversimplehttpserverthe http server module provides various classes for implementing http servers in python the contents of this module are split across three library modulesbasehttpservercgihttpserverand simplehttpserver httpserver the following class implements basic http server in python it is located in the basehttpserver module httpserver(server_addressrequest_handlercreates new httpserver object server_address is tuple of the form (hostporton which the server will listen request_handler is handler class derived from basehttprequesthandlerwhich is described later httpserver inherits directly from tcpserver defined in the socketserver module thusif you want to customize the operation of the http server in any wayyou lib fl ff