Can anybody assist me to get a Python script running on Hostgator Hosting that is shared? Sometimes with PHP mostly, but took a liking to Python, and have considered trying to have it going on the internet. The only method I have ever went Python is by using either the interpreter, or via a terminal, with >Python I attempted just uploading a hello world file towards the webserver, but all it results may be the script source. I spoken with hostgator, but all they might let me know was I have to make use of a dispatcher, that we cannot appear to locate a good example of. All I wish to know, is how you can create a <p>Hello</p> output towards the browser.

Thanks, and sorry if I am rambley, I have been Searching this on / off all week now.

Well, I acquired this from Hostgator's own support site.

Presuming your host is running Python 2.x, you'll be able to adapt the linked-to script the following:


print "Content-type: text/htmlrnrn"

print "<html><head>"

print "<title>CGI Test</title>"

print "</mind><body>"

print "<p>Test page using Python</p>"

print "</body></html>"

and set it inside your cgi-bin folder with permissions of 755.

Update: When it comes to "making your way aroundInch the cgi-bin folder: that'll rely on options your hosting package enables. Take a look at Bottle for any simple dispatcher which inserts in one Python module. You are able to deploy it using CGI,

import bottle

# Put your bottle code here, following a paperwork around the Bottle site

Further update: Aside from the Bottle paperwork, It is best to browse the Python paperwork about CGI.

I'm not sure about Hostgator, however, you would like your web server to visit your Python script being an executable CGI script. Which means which makes it executable and making certain there is a #! inside it and only putting it in cgi-bin, or setting your server to identify .py like a CGI script file extension. Here is a straightforward example script plus some context while using cgi module.