Code Point
September 08, 2010, 08:24:48 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Geshi Sintax Hilighting Mod Installed. Tens of languages available.
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: hello.py returns 500  (Read 3709 times)
anjanesh
Jr. Member
*

Karma: 0
Offline Offline

Posts: 4



« on: August 25, 2007, 06:41:06 AM »

Hi

Excellent Tutorial - got it working on my XP/Apache2 PC using mod_python !

But I cant seem to get anything running on 2 of my shared hosts - one using CGI and the other as mod !

For the one using as CGI, uploaded hello.py and set its permission to 755.
Path /usr/bin/python is also correct.
Code:
#! /usr/bin/python
def index():
    s = """
    <html>
    <body>
    <h2>Hello World!</h2>
    </body>
    </html>
    """
    return s
This is what I have in my .htaccess
Code:
Options -Indexes +ExecCGI
AddHandler cgi-script .py
But http://domain.com/hello.py return 500 Internal Server Error

Any idea why ?

CGI seems to be allowed in non cg-bin directories because I did the same for perl and it worked.

Thanks
Logged
Alter Lobo
Global Moderator
Jr. Member
*****

Karma: 10
Offline Offline

Posts: 65


« Reply #1 on: August 25, 2007, 11:33:39 AM »

The program you posted is Ok for mod_python. When using CGI use this one:

Code
#!/usr/bin/env python
print "Content-Type: text/html"
print
print """\
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
"
""
 

Change the path as necessary.
Logged
anjanesh
Jr. Member
*

Karma: 0
Offline Offline

Posts: 4



« Reply #2 on: August 25, 2007, 01:10:27 PM »

Actually path is fine - infact my host has made it such that most common paths would make it valid - guess he symlinked them.

But the problem I was having was because of \r\n after the shebang-line instead of just \n !

Now I got to figure out why its not working on my other host which provides mod_python. Since its a mod, shebang isnt required right ? But it prompts to download instead,
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!