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/python
print "Content-Type: text/html"
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 12:21 pm

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
12,339 Points
2014-11-20 11: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
n/a Points
2015-05-12 3:03 am

Hello,Is there a list of libraries that you have available for immediate use?Thanks,Kevin

Staff
1,198 Points
2015-05-12 3:30 pm
Hello Kevin,

We do not hold a list of libraries but we may write an article in the future with that list to help other developers as well.

Best Regards,
TJ Edens
n/a Points
2018-03-07 8:27 pm

I get Error 500 when I try to run this Hello World example on my webhostinghub account. Does this no longer work?

Staff
17,314 Points
2018-03-07 10:07 pm
Hello,

I just checked the script by following the steps above and it worked. Make sure you change the permissions. It should definitely still work.
n/a Points
2018-03-08 9:07 pm

I got it to work. I had the permissions set to 777, not 755, which I thought should work fine since it's a higher level of access, but apparently not. For future users: you can't enter the permission code directly in the File Manager, you have to check/uncheck certain boxes; 755 corresponds to User=read+write+execute, Group=read+execute, World=read+execute.

Staff
12,339 Points
2018-03-08 9:29 pm
Yes, 777 permission would be a security risk since anyone can write to and execute the script.

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!
Need More Help?

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.
}