How to Run a Python Script
You can run Python scripts on Web Hosting Canada's servers by following these instructions:
- Your script must have a .py extension (ex: script.py). If you use other extensions, you must add a file called .htaccess in the same folder as the script, containing AddHandler cgi-script .py (replace .py by the other extension).
- The first line of the script (also called Shebang) must be #!/usr/bin/env python.
- Upload the script to the server, by granting it "744" as permissions.
- Run the script directly in your browser, or through the command-line interpreter as follows: python name_of_the_script.py
Python script example (for testing):
# -*- coding: UTF-8 -*-
# to allow debugging
print "Content-Type: text/plain;charset=utf-8"
print "Hello World!"
Article ID: #HC5028