[Tutor] Setting up server for CGI

btkuhn at email.unc.edu btkuhn at email.unc.edu
Fri Oct 31 04:18:20 CET 2008

I'm not sure what you mean, "What directory do you run from?". I have 
the file saved as C:\cgihome\cgi\cgitest.py and I try running it by 
typing the following in the URL field: 
http://localhost:8000/cgi/cgitest.py . I tried changing the folder name 
to cgi-bin and get the same error. It says, "Nothing matches the given 
URI", even though the file is saved in the directory specified.

The Python program itself is saved in C:/Python25 but I don't think 
this makes a difference, especially since I can't run regular html 
files with my server.

Thanks again.

Quoting Kent Johnson <kent37 at tds.net>:

> On Thu, Oct 30, 2008 at 9:41 PM, <btkuhn at email.unc.edu> wrote:
>> I followed the instructions on a tutorial and created a "C:\cgihome" 
>> server, and then
>> created the following file:
>> C:\cgihome\server\cgihttpserver.py
>> It contains the following code:
>> [CODE]
>> import CGIHTTPServer
>> import BaseHTTPServer
>> class Handler(CGIHTTPServer.CGIHTTPRequestHandler):
>>    cgi_directories = ["/cgi"]
>> PORT = 8000
>> httpd = BaseHTTPServer.HTTPServer(("", PORT), Handler)
>> print "serving at port", PORT
>> httpd.serve_forever()
>> [/CODE]
>> This is supposed to set up a basic server on my system. When I run 
>> from the command line,
>> it seems to be working and displays the message "Serving at Port 8000".
> What directory do you run from? It should be the cgihome directory.
> Alternately, rename your /cgi directory to /cgi-bin and from the
> command line in the cgihome directory, run
> python -m CGIHTTPServer
> We had a very recent thread about this that might help; see the various
> "please help with simple python CGI script" posts here:
> http://mail.python.org/pipermail/tutor/2008-October/thread.html
> Kent

More information about the Tutor mailing list