Hello World Master

Tutorials, articles and quizzes on Software Development

A2Hosting > Articles

How to create a Python Application with A2 hosting

Lets make sure we’re in our cPanel interface

Then lets scroll down to Setup Python app and click on it:

We’ll be brought to a menu like this one

Click on the orange create application button on the top right

Now for the dropdown that says “Python Version” change to version to be 3.7.3, enter what you want your application root to be (I’m going to name my application A2Python), the application URL (mine will have the path of /a2python. These are the only things we enter in, heres what we have:

And when you’re done, the page should update to look like this

You can click on the open button to see your working Python application!

If you want to see where your Python project is location, go back to your cPanel menu and click on file manager, then search for the folder in your project root that contains the same name as the Application root we set up when creating our Python project. You should see:

  • Three folders, __pycache__, public and temp
  • A Python file names passenger_wsgi.py

This passesnger_wsgi.py should look like the following

import os
import sys


sys.path.insert(0, os.path.dirname(__file__))


def application(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain')])
    message = 'Hello Victoryflame!\n'
    version = 'Python %s\n' % sys.version.split()[0]
    response = '\n'.join([message, version])
    return [response.encode()]