Lines in your python file must use Unix line endings \n (0x0a).
Windows saves text files with a \r\n (0x0d 0x0a).
If you save in MS-Dos format from a windows editor you will have the wrong line endings.
To see if a file has the wrong line endings you can pipe it through xxd:
You can fix the line endings by one of the methods below:
Wordpad: Save in non-MS-Dos format. Save As… | Save as type: Text Document (instead of Text Document – MS-DOS Format)
Notepad++: open the file then Edit | EOL Conversion | Unix/OSX Format
vi test.py then (esc) :set fileformat=unix
The Content Line:
You need a line feed after the content line:
print (“Content-type: text/html\n”)
print (“Content-type: text/html”)
If you change your python interpreter to /usr/local/bin/python3.0 then scripts written in 2.x may fail (for example 3.x requires that print statements be in parentheses, etc.)
Check your script for syntax errors by running it in the shell: python test.py
Notice we specified the shell like this:
You can look and see what you have available like this:
Login to Site5 backstage
Site Admin to your site
Programming Center | Python
(You can also ls /usr/bin and /usr/local/bin to see what pythons are installed)