Support - Knowledge base

Giving you the answers you need

Why not try our knowledge base for instant help and advice to enhance your online experience with Register365? From within the knowledge base you can browse our frequently asked questions and find the right answers to help solve your queries.

Home  >  Scripting  >  Python  >  View Article

Python basics

Not enough ratingsNot enough ratingsNot enough ratingsNot enough ratingsNot enough ratings

Article

The path to Python on the shared Linux platform is:

#!/usr/bin/python

A basic 'Hello World', viewable in a browser, would be:

#!/usr/bin/python     
print "Content-type: text/html\n\n"     
print "<html>Hello World</html>"

Important: The file would need to be given a .py extension and the permissions of your script would need to be set to 755. You can alter permissions for your files in the File Manager section of your Control Panel or using your preferred FTP software.

IMPORTANT!
(taken from http://www.python.org/doc/2.6/howto/webservers.html#common-problems-with-cgi-scripts)

"The line endings must be of Unix-type. This is important because the web server checks the first line of the script (called shebang) and tries to run the program specified there. It gets easily confused by Windows line endings (Carriage Return & Line Feed, also called CRLF), so you have to convert the file to Unix line endings (only Line Feed, LF). This can be done automatically by uploading the file via FTP in text mode instead of binary mode, but the preferred way is just telling your editor to save the files with Unix line endings. Most proper editors support this"

Rate This Article

How useful was this article?

Not usefulA little usefulUsefulVery usefulEverything I needed