> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hostcloud.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Run a Python app in cPanel

> Host a Python web app, such as Flask or Django, on your HostCloud hosting with Setup Python App.

You can run Python web applications, such as a Flask or Django site, on HostCloud hosting. This guide shows you how to set one up in cPanel.

## Create the application

**1. Open Setup Python App**

[Log in to cPanel](https://kb.hostcloud.in/cpanel/log-in-to-cpanel.md), type **Setup Python App** in the **Search Tools** box and open it.

**2. Start a new app**

Click **Create Application**.

**3. Fill in the details**

| Field | What to enter |
| - | - |
| Python version | The version your app needs |
| Application root | The folder for your app's files, for example `myapp`. Keep it outside `public_html` |
| Application URL | The domain or address the app will answer on |
| Application startup file | The file that starts your app, for example `passenger_wsgi.py` |
| Application Entry point | The name of the app object in that file, usually `application` |

**4. Create**

Click **Create**. cPanel sets up the app, its folder and a private Python environment for it.

## Upload your code and install packages

**1. Upload your files**

Upload your app's files, including `requirements.txt`, to the application root folder. See [Upload files with File Manager or FTP](https://kb.hostcloud.in/cpanel/upload-files.md).

**2. Connect your app to the startup file**

Edit the startup file so it loads your app. For a Flask app saved as `app.py` with `app = Flask(__name__)`, the startup file can be just:

```python theme={null}
from app import app as application
```

For Django, point it to your project's `wsgi.py` instead.

**3. Install packages**

Back in **Setup Python App**, edit your app. Under **Configuration files**, add `requirements.txt` and click **Run Pip Install**.

**4. Restart the app**

Click **Restart**, then open the application URL in your browser.

> [!TIP]
>
> To run commands such as `python manage.py migrate`, copy the command shown at the top of your app's page in **Setup Python App**. Paste it into cPanel's **Terminal** to enter your app's Python environment. See [Use Terminal and SSH](https://kb.hostcloud.in/cpanel/ssh-and-terminal.md).

## After changing your code

Upload the changed files, run **Run Pip Install** again if `requirements.txt` changed, then click **Restart**.

## If the app shows an error

* **Check the log.** Your app's errors are written to a log file. Set a log file path on the app's page in **Setup Python App** if one isn't set, then open it in **File Manager**.
* **Check the startup file.** Most first-time errors come from a wrong file name or entry point.
* **Restart after every change.** The app keeps running the old code until you restart it.

> [!NOTE]
>
> Apps that run heavy background work around the clock, or need their own services such as Redis, may outgrow shared hosting. A HostCloud VPS gives you full control. See [Connect to your Linux VPS with SSH](https://kb.hostcloud.in/vps/access-your-vps-over-ssh.md).

Still stuck? [Open a ticket](https://kb.hostcloud.in/support/open-a-ticket.md) with your app's URL and any error shown on the Setup Python App page.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.