1. Start with the following script called hello.py containing this code

Code:
#! /usr/bin/python

print "Content-type: text/html\n\n"
print "<html>Hello world!</html>"


2. Create the file hello.py in /home/username/public_html/cgi-bin    (replace username with your cpanel username)

3. Correct the permissions with the following commands:

Code:
chmod +x /home/username/public_html/cgi-bin/hello.py

At that point, the script should work using http://domain.com/cgi-bin/hello.py

4. If you would like the script to run outside the cgi-bin, place the following content into /home/username/public_html/.htaccess file:

Code:
Options +ExecCGI
AddHandler cgi-script .py
Was this answer helpful? 0 Users Found This Useful (2 Votes)