[Tutor] cgi not executed when accessed through browser

alan.gauld@bt.com alan.gauld@bt.com
Tue, 23 Jul 2002 14:06:06 +0100


> My first simple one.
> 
> Listing of file first.py in 
> directory:/www/www.howlermonkey.net/cgi-bin
> 
> #!/usr/local/bin/python
> print "Content-type: text/html"
> print
> print "<title>First program</title></head>"
> print "<body bgcolor=\"FFFFFF\" text=\"000000\" link=\"0000FF\">"
> print '<P>'
> print "Hello world!"
> print '<P>'
> print '</body></html>'
> 

print ''' 
is your friend for HTML generation...as in:

print '''Content-type: text/html

<title>First program</title></head>
<body bgcolor=\"FFFFFF\" text=\"000000\" link=\"0000FF\">
<P>
Hello world!
</P>
</body></html>
'''

Looks nicer and is easier to maintain - less concerns 
over a missing quote or mixups between " and ' characters.

Alan g.