How to Host Flask Application on CPanel?

Most of the people know how to write python services on local host and when time comes to deploy it, they are confused. If you don’t know how to write application in flask? then learn here. To host flask application, you have following options.

In this chapter i will be focusing on host flask application on cpanels like NameCheap. The simple steps to host flask application on CPanel are:-

  • Step 1: Log in to cPanel
  • Step 2: Create a Python Application from there (option available in Account)
  • Step 3: Flask Application
    • Write Flask Application OR
    • Upload the Flask Application to cPanel
  • Step 4: Configuring our WSGI file (file name
  • Step 5: Install Project Requirements
  • Step 6: Restart the Flask Application
  • Step 7: Open URL

1: Log in to cPanel

Open your cpanel, enter user name and password and wait for panel to open as shown.

host flask application cpanel

2: Create a Python Application

In Search bar type “Python” or manually search for “Setup Python App”. Click on this option and wait for next window.

host flask create python app

After clicking on Setup Python App, You will have following window. In my case there are many already running services (don’t worry about that). Now its time to create your first application. Click on Create Application option as shown given image.

Python services in Cpanel

After clicking on Create Application, you will enter into another windows as shown below. There will be following options:

  • Python Version: You can select from available Python versions
  • Application root: It is the physical address to your application on server. This is name of folder where all files and folders related to this project will be stored
  • Application URL: This is the public URL, with which people will access this application
  • Application Startup File: file will be automatically created in folder
  • Application Entry Point: This variable will be used in Flask Application
Deploy flask on cpanel

For this tutorial i filled values as shown:

Flask Application NameCheap

Click on Create, this will take sometime and your service will be ready. In order to verify you should go to File Manager and check that folder and all other files.

File Manager CPanel

Click on File Manager and Search for Project name you have entered in previous step.

Following files and folders will be available there:

  • public
  • tmp

3: Flask Application

Now it’s time to create Flask Application. To do this you can upload already coded files by using Upload option or you can create file here as shown:

host flask application cpanel

You will see that file with name “” will be created there in same folder. Select edit file option in order to write flask code or make changes in already written code. Write following code

from flask import Flask

app = Flask(__name__)

# this is the entry point
application = app

def hello():
    return "Congratulation! You service Hosted on CPanel"

if __name__ == "__main__":

Save file by clicking on save changes (top right corner) and close the file.

4: Configuring our WSGI file

Now edit file, comment everything and add following line to this file

from myapp import application

If you hit URL “”, you will recieve 500 server error, because you don’t have libraries such as Flask installed. You have to installed libraries first.

5: Install Project Requirements

There are two ways to install project requirements.

  • Using Terminal
  • Using Requirements File

From terminal follow given steps.

host flask application cpanel Terminal

Click on Terminal and once opened, open Python Virtual Environment here. The path of virtual environment can be taken from:

host flask application cpanel

Copy this line just by clicking on line. Paste in Terminal and you will enter Virtual Environment, Now you can install any library you want using pip command such as:

pip install flask

The other way is to create requirements file and upload that file on server and then apply command as shown:

host flask application cpanel

6: Restart the Flask Application

Finally go and restart flask application. Now the service is available.

host flask application cpanel

7: Open URL

Type URL in browser such as Google Chrome (in my case it is “”)

host flask application cpanel
39730cookie-checkHow to Host Flask Application on CPanel?

One Reply to “How to Host Flask Application on CPanel?

  1. I have read tons of tutorial without success, and I followed yours and it works !

    Thanks a lot !

Leave a Reply