CGIHTTPServer.py
Alex Martelli
aleaxit at yahoo.com
Thu Jan 4 06:43:38 EST 2001
"alan runyan" <runyaga at thisbox.com> wrote in message
news:7F5BC4310EDD615A.1D87832E39807480.8066D4EF5FF33D4C at lp.airnews.net...
> I'm playing around CGIHTTPServer.py and have some problems that I can seem
> to fix. any help would be greatly appreciated.
>
> in the Library Reference it shows its availability as Unix only, why not
> Windows? it seems to work just fine on Windows.
A bug in the docs, I think; it didn't USE to work on Windows, as of
Python 1.5.2 (it used fork, making it unix-only) -- its applicability
has been enhanced in 2.0, but the docs may not reflect that yet.
The docstring in the Python sources is very clear, though:
'''
If the os.fork() function is not present (e.g. on Windows),
os.popen2() is used as a fallback, with slightly altered semantics; if
that function is not present either (e.g. on Macintosh), only Python
scripts are supported, and they are executed by the current process.
'''
> GET appears to work just fine on both unix and win32. (this is a
> SimpleHTTPServer, not CGIHTTPServer's job)
Why not? GET can perfectly well reach a CGI, not just a simple
page. Form-parameters get appended to the URL in the ?name=value
syntax, in GET's case.
Simple test: make a cgi-bin directory and copy cgi.py into it.
Now, run cgihttpserver.py from the directory just above it. Now
from your browser visit url http://localhost:8000/cgi-bin/cgi.py?foo=bar:
it should return a large 'page' with all sorts of info, including
Form Contents:
foo: <type 'instance'>
MiniFieldStorage('foo', 'bar')
and work uniformly across all platforms. OK so far?
Now, build a very simple correct HTML file for this cgi, e.g.:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML>
<HEAD><TITLE>CGI POST test</TITLE></HEAD>
<BODY>
<FORM ACTION="http://localhost:8000/cgi-bin/cgi.py"
METHOD="POST" ENCTYPE="application/x-www-form-urlencoded">
<INPUT TYPE="text" NAME="command" SIZE=80>
<INPUT TYPE="submit" NAME=".submit">
</FORM>
</BODY>
</HTML>
visit it with your browser, enter some text, clic on 'submit'.
You should again receive the same page as above, except of
course the 'form contents' will be a bit different.
This works just fine for me on Windows NT 4 with IE 5.5. Can
you reproduce your observed problems with this very simple test?
Alex
More information about the Python-list
mailing list