<br />
Hi everyone,<br />
<br />
I am new to programming and have been programming with Python for about 2.5
months. After learning the basics of the language I am trying to teach myself
CGI with Python. I've<br />
come across a few resources that teach CGI, but I am having much trouble setting
up a<br />
server to view CGI scripts on my browser (Note: some of terminology may be
wrong). I am running Windows XP with a Firefox browser.<br />
<br />
Here is what I've tried so far:<br />
<br />
I followed the instructions on a tutorial and created a "C:\cgihome"
server, and then<br />
created the following file:<br />
<br />
C:\cgihome\server\cgihttpserver.py<br />
<br />
It contains the following code:<br />
[CODE]<br />
import CGIHTTPServer<br />
import BaseHTTPServer<br />
class Handler(CGIHTTPServer.CGIHTTPRequestHandler):<br />
cgi_directories = ["/cgi"]<br />
PORT = 8000<br />
httpd = BaseHTTPServer.HTTPServer(("", PORT), Handler)<br />
print "serving at port", PORT<br />
httpd.serve_forever()<br />
[/CODE]<br />
<br />
This is supposed to set up a basic server on my system. When I run from the
command line,<br />
it seems to be working and displays the message "Serving at Port
8000".<br />
<br />
According to the tutorial I should then be able to run CGI scripts by saving
them in<br />
C:/cgihome/cgi , and then opening in the browser (after running the server
script on the<br />
command line). So for instance I wrote this script:<br />
[CODE]<br />
#!c:\Python25\python.exe<br />
<br />
print "Content-Type: text/html"<br />
print<br />
print """\<br />
<html><br />
<body><br />
<h2>Hello World!</h2><br />
</body><br />
</html><br />
"""<br />
[/CODE]<br />
and saved it as C:\cgihome\cgi\cgitest.py . When I try opening it in my browser,
though,<br />
I just get 404 error: "File not found". This shows up both in the
browser window and the<br />
command prompt window. When I try using a plain .html file saved in C:\cgihome
instead, I<br />
get the same error. I can't get anything to run. I'm sure I'm doing something
wrong, but<br />
I don't know what. I have also tried downloading the Apache server as well, but
it is 10<br />
times more complex than my simple server script, and geared towards Linux users
who know what they are doing.<br />
<br />
Can someone please explain to me like I'm a child how to set up a basic web
server that I<br />
can run CGI scripts on?<br />
<br />
Thanks very much.