Saturday, January 19, 2013

Use Python 2.7 with Hostgator.com

In .htaccess of root directory:

AddType text/html py
AddHandler cgi-script .py

In the same .htaccess file, this Apache script hides ".py" extensions:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.py -f
RewriteRule ^(.*)$ $1.py

For your script example.com/filename.py, you can type example.com/filename or example.com/filename.py

Python path:
#!/usr/bin/python
print "Content-type: text/html\n\n";
print "";
print "CGI Test";
print "
";
print "Test page using Python
";
print "
";


No comments :