Why does a Web browser running under Linux show Python CGI scripts as plain text?!

Zorba ghostagain at operamail.com
Tue Feb 4 07:51:17 EST 2003


Joseph has got it right. I had incorrectly coded in the print line as
"Content-Type: text/plain"--I'm guessing I inherited that from a
Python tutorial where someone was doing no more than printing 'hello'
to the browser. And since I did all my coding in Internet Explorer, I
never found the mistake! I have verified that changing this line to
"text/html" solves the problem.


Joseph Wilhelm <jwilhelm at outsourcefinancial.com> wrote in message news:<mailman.1044309386.378.python-list at python.org>...
> > Can anybody tell me why this is happening, and what the cure is? I
> > can't believe that every Pythonista running Linux on their desktop is
> > unable to view CGI pages coded in Python - the whole thing is either
> > laughable or mind-boggling, an open-source nightmare.
> 
> I just viewed the page myself, and I didn't see any Python code; all I
> saw was the HTML. The reason for this is that you didn't send a
> Content-Type header. Internet Explorer still interprets it as HTML
> because it's trying to think it's smarter than you. Try adding this to
> the top of the scripts before any other output:
> 
> print "Content-Type: text/html"
> print
> 
> The extra print is just for a blank line to terminate the headers. After
> that it should just work.
> 
> --Joseph Wilhelm




More information about the Python-list mailing list