I know this is an old question, but I also encountered a 500 error using the host giant (to indicate that I stopped trying a year ago). A few days ago, I decided to try again after my “ textbook ”, and it did not work again.
I will try something simpler:
#!/usr/bin/python import sys print sys.version_info
I got 500 errors again, but after a conversation with support, they gave a log message saying:
[error] [client 192.xxx] invalid header from script. Bad title = (2, 6, 6, 'final', 0): test1.py
With this information (the log message contained python, so it somehow ran) I found this post on the Unix site where I got this:
As the HTTP specification (and the error message from your HTTP server) indicates, you need one blank line between the HTTP headers and the body, otherwise the server does not know where the headers end and the body begins.
I changed my script to:
#!/usr/bin/python print "" import sys print sys.version_info
And it worked !. Oddly enough, after the successful execution of this script, the example in the tutorial (code below) now works for me as well
#!/usr/bin/python print "Content-type: text/html\n\n"; print "<html><head>"; print "<title>CGI Test</title>"; print "</head><body>"; print "<p>Test page using Python</p>"; print "</body></html>";
Why does it work now? I have no idea, but at least I hope this answer helps someone who is dealing with a lack of hostgator support.