Re: Help: Uploading .zip to Python CGI

From: Will Stuyvesant (hwlgw_at_hotmail.com)
Date: 12/07/03


Date: 7 Dec 2003 01:47:02 -0800

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?


Relevant Pages

  • Re: Whats with "long running processes" ?
    ... extension modules for apache. ... FWIW, when apache is configured to use mod_python, it starts a first python interpreter process at startup, then some more python "sub-interpreters" when needed, according to your configuration. ... most basic way to deliver dynamic content from a web server like apache is to use CGI - which means that on each http request, ... CGI or mod_python - but the first solution is very inefficient, and the second is not really appropriate for shared hosting given how mod_python works. ...
    (comp.lang.python)
  • Re: Not a Debian question, but you guys know this stuff...
    ... > that the more experienced ones may know how to help me in Windows and Linux. ... Apache support running on Windows. ... >> * post your question to a forum where it's off topic ... initial message would have been better suited for *their* mailing lists. ...
    (Debian-User)
  • Re: Python/Apache Oddness On OSX
    ... > import OK via command line python. ... > from a cgi script, python fails to find the module. ... > something to do with the symlink, as the CGI works OK if I copy the ... If running OS supplied Apache, it runs as the user "www". ...
    (comp.lang.python)
  • Re: Developing PHP under Windows - Why?
    ... Windows 2000, Apache 2, Microsoft SQL Server, and PHP. ... We went with the Windows route mainly for human resource reason. ... I knew virtually nothing about Linux at the time - and very little about Apache. ...
    (comp.lang.php)
  • RE: Webservers
    ... At least with the GUI, you run help, and just click the link in help to ... Finally, there are a billion books out there on windows, and technet as ... But, of course, if you know 'NIX, it is easier to administer for you, ... There are are some GUI apache configuration tools ...
    (Security-Basics)