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

Joseph Wilhelm jwilhelm at outsourcefinancial.com
Mon Feb 3 16:56:10 EST 2003


> 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