[Tutor] RE: Help: CGI Error in a Python Application
mhansen at cso.atmel.com
mhansen at cso.atmel.com
Thu May 6 10:48:32 EDT 2004
----- Original Message -----
>From "Crabtree, Chad" <Chad.Crabtree at nationalcity.com>
Date Wed, 5 May 2004 13:46:03 -0400
To "'ajay singh'" <ajay_4may at yahoo.co.in>
Cc "'tutor at python.org'" <tutor at python.org>
Subject RE: [Tutor] Help: CGI Error in a Python Application
> ------------------------------------------------
> CGI Error
> The specified CGI application misbehaved by not
> returning a complete set of HTTP headers. The headers
> it did return are:
> -----------------------------------------------
>
>
> The Python code is as below:
>
> --------------------------------------------
>
> #!c:\python23\python
> import cgi
> import sys,os
> import string
> import MySQLdb
> db=MySQLdb.connect(host="localhost",user="root",passwd="",db="power")
> cursor=db.cursor()
>>***************************
>>print "Content-Type: text/plain\n\n"
>>****************************
Shouldn't that be ..
print "Content-Type: text/html\n\n"
or does it make a difference?
Also, this is a nit, but it should also print the doc type
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 4.01//EN"
"http://www.w3c.org/TR/html4/strict.dtd">
for HTML 4 or
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
for XHTML transitional...
In any event, it might be a good ideas to check your output through the w3c's validator...
http://validator.w3.org/
I realize if you are just experimenting/testing code, then the doc type and validator probably isn't necessary. If it's production code, then I strongly suggest putting in the doc type and validate your output to make it clean HTML or XHTML.
Mike
More information about the Tutor
mailing list