Wichid Nixin
Wichid Nixin

Reputation: 285

Python CGI - Script outputs source of generated page

I have a CGI script that I wrote in python to use as the home page of the website I am creating. Everything works properly except when you view the page instead of seeing the page that it outputs you see the source code of the page, why is this? I dont mean that it shows me the source code of the .py file, it shows me all the printed information as if I were looking at a .htm file in notepad.

Upvotes: 0

Views: 532

Answers (2)

aar cee
aar cee

Reputation: 249

Add the following before you print anything

print "Content-type: text/html"

Probably your script is not getting executed. Is your python script executable? Check whether you have the script under cgi-bin directory.

Upvotes: 2

Burhan Khalid
Burhan Khalid

Reputation: 174748

The default Content Type is text, and if you forgot to send the appropriate header in your CGI file, you will end up with what you are seeing.

Upvotes: 1

Related Questions