Help: Uploading .zip to Python CGI

Will Stuyvesant hwlgw at hotmail.com
Sun Dec 7 10:47:02 CET 2003


The problem I described in this thread is with Apache, not with
Python!  And the unix Apache at my work has no problems, its only the
Windows Apache versions.  So the Apache peeps will probably say it's a
*Windows* problem 0-)

I found out with the following:  I can now avoid the first HTML page
with the .zip upload, instead I upload the .zip to my Python CGI
program with this little program:


import urllib
import webbrowser

webserviceURI = r'http://localhost/cgi-bin/mycgiprogram.py'
startpageName = 'start.xml'


# instead of a HTML page with INPUT type=file just read the file
fp = open(fname, 'rb')
data = fp.read()
fp.close()

# all CGI parameters in a dict, and encoded
params = urllib.urlencode({ 'yourfile': data })

# call the CGI program and read what it returns
f = urllib.urlopen(webserviceURI, params)
webpage = f.read()

# save it locally in a file
wpfp = open(startpageName, 'w')
wpfp.write(webpage)
wpfp.close()

# show it in your browser
webbrowser.open(startpageName)


-- 
If pro is the opposite of con, what is the opposite of progress?




More information about the Python-list mailing list