Newbie Question!

Steve Holden sholden at holdenweb.com
Tue Aug 7 12:36:15 EDT 2001


[posted & mailed]

----- Original Message -----
From: <fleet at teachout.org>
To: "python list" <python-list at cwi.nl>
Cc: "Steve Holden" <sholden at holdenweb.com>
Sent: Tuesday, August 07, 2001 12:17 PM
Subject: Re: Newbie Question!


> >   From: "Steve Holden" <sholden at holdenweb.com>
> >Subject: Re: Newbie Question!
> >
> >Well I can answer your first question: see
> >
> >    http://pydish.holdenweb.com:8080/DeptHome/python
> >
> >(which is itself a pure Python web) for a small CGI server in Python.
I
> >think you'll be surprised how small. Run that from the same directory
as an
> >index.html file containing your favored HTML page, and access is at
> >
> >    http://127.0.0.1:8000/
>
> Assume two givens:
>   1.  The script works as advertised - attested to by "bob."
>   2.  I'm clueless - can be attested to by most regular readers of
this list/group for the
> past couple of weeks.
>
> I get the following when I attempt to run the script:
>
> [/home/dev/cbamc]$ python cgiserver.py
> localhost.localdomain - - [07/Aug/2001 11:32:26] code 403, message
Directory listing not
> supported
> localhost.localdomain - - [07/Aug/2001 11:32:26] "GET / HTTP/1.0"
403 -
> Traceback (innermost last):
>   File "cgiserver.py", line 5, in ?
>     httpd.serve_forever()
>   File "/usr/lib/python1.5/SocketServer.py", line 195, in
serve_forever
>     self.handle_request()
>   File "/usr/lib/python1.5/SocketServer.py", line 210, in
handle_request
>     request, client_address = self.get_request()
>   File "/usr/lib/python1.5/SocketServer.py", line 223, in get_request
>     return self.socket.accept()
> KeyboardInterrupt <---- me getting out
>
> The directory contains only 'index.html' (rather lengthy) and
'cgiserver.py.'
>

Seems like it might be a versioning problem, if indeed there really is
anything wrong at all. From the traceback, it looks like your server was
sitting there waiting to accept a request. I'm guessing you didn't use
the right URL in your browser! In which case see below for the right
one...

It works fine for me under Python 2.0 on Windows 98, for example:

D:\Temp>python cgis.py

[Access root page as http://127.0.0.1:8000] <<< NOTE: the server serves
port 8000

localhost.i95.net - - [07/Aug/2001 12:25:22] "GET / HTTP/1.0" 200 -

and sure enough the (very small) index.html from the D:\Temp directory
appears in my browser. I wasn't aware of any breakages under 1.5.2, but
it's rather a long time since I used it. If you don't like putting a
port number in your URLs, just change "8000" to "80" in the server code.

Once you've seen your index.html page, you can add others, and call them
up too, (by name, of course), and even build hypertext links between
them. Good luck!

regards
 Steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list