• Advertisement
Sign in to follow this  

python cgi errors and setup

This topic is 4245 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Now I have just gotten myself a nice new web host, that suport python. I want to use python to write the backend of my site. Now the problem arives, I cant get a single script to work.. *I am pretty fluent in python (from a win32 perspetive only thought) (note the server ownly suports python thought cgi not mod_python. :( ) Anyway. I get a 500 error everytime that I try to run a .py file in my cgi-bin. The file is chmod'ed 755 (tried with 777 no luck) Here is the example:
#!/usr/bin/env python

# Headers and an extra blank line
print 'Content-type: text/html'
print

# Body
print '<html><body><p>Hello World!</p></body></html>'

Now I belive that the first line is the cause to all these problems. Its suposed to point to the python runtime? After looking around the net I saw many diffrent 1lines. Among: #!/usr/bin/python #!/usr/local/bin/python I tried all these to no more success. I get a 500 internal server error each time. Is there any other locations that the webhost might have hidden the python runtime? Or is this not the cause of the problems? Please give me a hand here.

Share this post


Link to post
Share on other sites
Advertisement
Another thing to try:
Make sure your file has unix (\n only) line endings. If saving on windows you'll get \r\n and that'll prevent your script from running (Python doesn't care about this, but the #! line is interpreted before python even starts)

Also, make sure the #! line is at the very beginning of your script (No lines before it, even comments or blank lines)

Have you checked your host's site? They may have a FAQ showing the location of the python binary.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement