Executing Python scripts

Status
Not open for further replies.

peticom

New Member
Messages
1
Reaction score
0
Points
0
Hi,
where you can run the python scripts or where should I publish these scripts. cgi-bin folder are not executed.
Thanks
Peter Jambor
 

daman371

New Member
Messages
130
Reaction score
0
Points
0
Should work fine in cgi-bin as long as python is installed and your scripts have the shebang line at the very first line. I also think that the file has to have *nix line breaks.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Code:
#!/usr/bin/env python
import os
import sys


print("Content-type: text/html")
print("")

print("<html>")
print("<body>")

print( "GET / POST Information")
print("<pre>")


print "Request method: " , os.environ[ 'REQUEST_METHOD' ]
print "Query string: " ,  os.environ[ 'QUERY_STRING' ]
count = 0 
for line in sys.stdin:
    count = count + 1
    print line
    if count > 100:
        break
print ""





print("</pre>")

print("</body>")
print("</html>")

Sample code.

Permissions set to 0755

Add line

Code:
AddHandler cgi-script .py

to .htaccess

Place script anywhere in website.
 
Status
Not open for further replies.
Top