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

Paul Rubin phr-n2003b at NOSPAMnightsong.com
Mon Feb 3 22:37:17 CET 2003


ghostagain at operamail.com (Zorba) writes:
> I have also posted this on the comp.os.linux.help newsgroup, where it
> may be more appropriate.

Your web server is configured incorrectly.  The right newsgroup for
this type of server problem is comp.infosystems.www.servers.unix.


> pages, if you want to take a look). These work fine when I'm browsing
> in any browser on my Win98 desktop--but when I use any browser in
> Linux (Opera, Konquerer, Netscape 7.0, doesn't matter), the pages are
> displayed as plain text--in other words, I am shown the underlying
> Python script.

I'm looking with Mozilla 1.2.1 and I don't see the Python script.  I
see the HTML page incorrectly sent as a text/plain file, which has
some Javascript in it that you might be mistaking for Python.

> I tried to tell Opera to view .py scripts as text/html, but this did
> not fix the problem. Not sure what else to do, since the situation
> makes no sense to me. I would have thought Web browsing should be as
> independent as possible from the client OS--but apparently I am wrong,
> at least when it comes to Linux.

The Linux browsers are following the Content-type: text/plain header
that the server sends.  I suspect MSIE is aggressively ignoring the
header and rendering the file as HTML.  MSIE likes to do stuff like that.

> 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.

Put 

  AddHandler cgi-script .py

into your httpd.conf or .htaccess file.  Also, you are running Apache
1.3.6 so you should upgrade to a newer version because of security
fixes.




More information about the Python-list mailing list