[Tutor] Setting up server for CGI
Kent Johnson
kent37 at tds.net
Fri Oct 31 03:29:13 CET 2008
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