[Tutor] please help with simple python CGI script
aivars868 at gmail.com
Fri Oct 24 16:25:21 CEST 2008
I am learning python.
I start the python CGI server like this:
python -m CGIHTTPServer (this syntax I saw in Wesley Chun's Core
Python Programming chapter 20.5)
The server starts in command prompt on windows XP by answering:
Serving HTTP on 0.0.0.0 port 8000...
Next I want to run this simple CGI script (from Deitel Python How to
Program chapter 6). it is supposed to print out current date and time
in a browser
print """Content-type: text/html
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>""" % title
printHeader("Current date and time")
And The server prints the script text in the browser. It does not run
The server response is 200.
The script itself runs OK if being run from python/command line
I also could not run the script from wesley chun's book. I think also
because it seems the python cgi web server does not understand that it
should run the script and not to print it out in web browser
I am using python 2.5 on windows XP.
What I am missing?
More information about the Tutor