0

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.

0

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

1 Comment

I had this line <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> in the code that I thought took care of that but i guess not... I added print "Content-type: text/html" to the beginning of the script and it works now thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.