Python scripts can be ran on our servers within your cgi-bin folder. In this article, we'll show you how to setup a basic 'Hello World' python script.

1. The first thing you'll need to do is create hello_world_python.py. Using either the File Manager (of use ftp), create a file named hello_world_python.py. This file should be created in your cgi-bin folder.

python_create_new_file

2. Edit the hello_world_python.py file and input the following code:

#!/usr/bin/env python
print "Content-Type: text/html"
print
print """\
<html>
 <head>
  <title>Python - Hello World</title>
 </head>
 <body>
  Hello World
 </body>
</html>
"""

hello_world_python_code

3. After saving the file, change the permission of hello_world_python.py to 755. Within the File Manager, you can do this by right-clicking on the file and choosing "Change Permissions". Then, set the values to 755.

change_permissions

4. After updating file's permissions, visit yourdomain.com/cgi-bin/hello_world_python.py in your browser. You should see "Hello World" printed to the screen!

hello_word_python

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Did you find this article helpful?

Comments

n/a Points
2014-11-20 4:21 am

I'm trying to install addon libraries for Python onto the server, but I'm not really sure how to go about it. I've set up a .bashrc file in the root folder, and put the libraries into .local/lib/site-packages, but my cron job doesn't seem to find the libraries. Any help?

Staff
9,475 Points
2014-11-20 3:20 pm
Hello Simon,

Thank you for contacting us. Since this is a shared server environment, you will not be able to install python libraries.

Python is installed on our servers however, so you should be able to use existing libraries.

The path is:
/usr/bin/python

Thank you,
John-Paul

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!

Help Center Search

Current Customers

Email: support@WebHostingHub.com Ticket: Submit a Support Ticket
Call: 877-595-4HUB (4482)
757-416-6627 (Intl.)
Chat: Click To Chat Now

Ask the Community

Get help with your questions from our community of like-minded hosting users and Web Hosting Hub Staff.

Not a Customer?

Get web hosting from a company that is here to help.