In this post we will enable Python CGI for Hostgator
Create a .htaccess file and put following contents in this file:
1 |
AddHandler cgi-script .py |
This will make the web server to interprete .py file as Python CGI script.
Next create a python file (named test.py here) with following code:
1 2 3 4 5 |
#!/usr/bin/python print 'Content-Type: text/html\n\n' print 'hello' |
And set this file's permission setting so that Owner, Group and Public have "execute" permission for this file (Or set 755 permission simply)
Visit http://server_address/app_path/test.py, you will see a page with "hello" printed.
Note
The first two lines of code is necessary, otherwise you will get a "500 Internal Server Error".