Python Support

While our shared hosting environment is optimized for the LAMP stack (Linux, Apache, MySQL, PHP) some other languages such as Python can be used to host web pages with additional configuration.

You can run scripts directly from the command line (via SSH or cron jobs) using the system Python at /usr/bin/python3.

Here's a quick way to test it. Create a file called hello.py in your home directory with the following:

#!/usr/bin/python3
print("Hello, world!")

Then from SSH, run: python3 hello.py

You should see "Hello, world!" printed back. That same script can also be scheduled as a cron job in cPanel under Cron Jobs if you want it to run automatically.

If you'd like a Python script to respond to web requests in your browser, the simplest approach is a CGI script. Create a file called hello.py inside your public_html/cgi-bin directory with this content:

#!/usr/bin/python3
print("Content-Type: text/html\n")
print("<h1>Hello, world!</h1>")


Then set the file permissions to 755 (you can do this in File Manager or with chmod 755 hello.py over SSH). Visiting [yourdomain.com]/cgi-bin/hello.py should then display the message in your browser.

One more thing worth mentioning: if you're planning to build out a full Python web application, cPanel offers a Phusion Passenger application tool under "Setup Python App" that can approximate what a Python host might do with gunicorn or uWSGI. Our experience with this is limited. If you plan to host a large Python application you may wish to find a more Python-focused host.

  • 17 användare blev hjälpta av detta svar
Hjälpte svaret dig?

Relaterade artiklar

Seeing list of files, not home page

Like all linux-based web servers, your 'home page' must be named index.htm or index.html,...

Additional Domains in your cPanel account (parked and add-on domains)

Most of our web hosting packages allow you to have multiple domain names. The additional domains...

Get Web Hosting and EMail Instructions resent to you

When you first signed up for Web Hosting service with QTH.com, you would have received an email...

AWStats Statistics - Definitions

Here is a link to a page that defines each of the terms in AWStats, including Unique Visitor,...

Password Protected Directories

You can create password protected directories on your web site by using your cPanel web hosting...