Get a free website with any plan

See how
APPLICATIONS

Running a Flask or Django app with Setup Python App

Last updated

IN SHORT

Flashcloud lets you run Flask and Django applications on shared hosting using cPanel's Setup Python App tool. The tool creates an isolated Python 3.11.16 virtual environment and connects your WSGI code to the LiteSpeed web server. Place your code outside public_html and assign it to a dedicated subdomain for reliable routing.

You can run Python web applications like Flask and Django directly on Flashcloud shared hosting. The setup does not require a VPS or manual reverse proxy configuration. You create the environment using cPanel's Setup Python App tool, which isolates dependencies in a dedicated virtual environment and hooks your code into the LiteSpeed web server.

The Python runtime is fixed to Python 3.11.16 on our servers. For best results, assign your Python application to its own subdomain rather than a subpath of an existing website. If your main domain runs WordPress, its rewrite rules can intercept requests and cause 404 errors on downstream application routes.

Creating the Python application

Log in to cPanel from your hosting service page in the portal. Open Setup Python App under the Software section.

Click Create Application and configure the core fields:

  • Python version: Select 3.11.16.
  • Application root: The folder inside your home directory where your code lives, such as flaskapp or myproject. Do not place this inside public_html.
  • Application URL: Select your domain or subdomain from the dropdown. You can leave the path empty (root) or specify a subfolder. Using a dedicated subdomain with an empty path is strongly recommended.
  • Application startup file: The entry script, usually app.py for Flask or passenger_wsgi.py.
  • Application Entry point: The callable WSGI object inside your startup file, typically app for Flask or application for Django.

Click Create. The tool generates starter files inside your application root (including app.py, passenger_wsgi.py, public/, and tmp/), creates a virtual environment at ~/virtualenv/<root>/3.11, and writes server directives (PassengerAppRoot, PassengerBaseURI, PassengerPython) into the relevant .htaccess file. Never remove those comment markers from .htaccess, as LiteSpeed relies on them to serve your app.

Uploading code and managing dependencies

Once the skeleton exists, move your actual project files into the application root. You can transfer files using the File Manager tile in the portal, an FTP client, or Git. If you use version control, you can review deploying a Python app (Flask or Django) and our guide to using the Git Version Control tile to pull changes from remote repositories.

Your requirements.txt file is not automatically detected upon upload. To install your dependencies through the interface:

  1. Navigate back to Setup Python App and click the pencil icon next to your application.
  2. Locate the Configuration files section.
  3. Type requirements.txt into the text box labeled Add another file and press enter, then press Enter.
  4. Click Run Pip Install. A dropdown will let you select requirements.txt.
  5. Wait for the confirmation toast stating PIP Install completed successfully.

There is no in-browser terminal tool in cPanel. If you prefer using a command-line interface to install packages or manage dependencies, open your terminal and connect via an SSH client using the credentials from cPanel's SSH Access tool, similar to running Composer in our Symfony and CakePHP guides. The top banner inside Setup Python App displays the exact command to activate your virtualenv over SSH:

source /home/username/virtualenv/flaskapp/3.11/bin/activate && cd /home/username/flaskapp

Configuring Flask versus Django

The difference between running Flask and Django comes down to where the WSGI callable is defined.

Flask configuration

A minimal Flask application exposes the callable directly in your startup script. For an app.py file containing app = Flask(__name__), set the Application startup file to app.py and the Application Entry point to app. The generated passenger_wsgi.py will bridge this automatically, or you can import your callable directly inside passenger_wsgi.py:

from app import app as application

Django configuration

Django projects isolate the callable inside a wsgi.py file within your inner project folder (for example, myproject/wsgi.py). To hook this up:

  • Set the Application startup file to passenger_wsgi.py.
  • Set the Application Entry point to application.
  • Edit passenger_wsgi.py in your project root to point to your Django WSGI handler:
import os
import sys

sys.path.insert(0, os.path.dirname(__file__))
from myproject.wsgi import application

To run database migrations such as python manage.py migrate, connect to your account using an SSH client, run the virtual environment activation command shown in the cPanel interface, and execute the migration commands directly from your project root.

Environment variables and debugging

Never hard-code sensitive database passwords or API credentials into your application files. Setup Python App provides an environment variables manager:

  1. Inside your application view, scroll to Environment variables.
  2. Click Add Variable.
  3. Enter the variable Name and Value, then click Done.
  4. Click Save at the top of the interface, then click Restart.

The panel writes these entries as SetEnv directives in your directory's .htaccess. Your code reads them cleanly through standard Python:

import os
db_password = os.environ.get('DB_PASSWORD')

If your application crashes on startup or returns a 500 error, check stderr.log inside your application root directory. All unhandled Python tracebacks and WSGI import failures are written there.

When to contact support

If your application reports internal errors, check stderr.log and verify your requirements.txt packages completed installation. If your application works locally but crashes on import, or if you encounter file permission locks while updating your virtual environment, open a ticket via the portal (Support → New ticket). Our team can inspect the LiteSpeed runner logs to help diagnose underlying server faults.

Common questions

What Python version can I choose?

Python 3.11.16 is the only supported version. The runtime is fixed on Flashcloud servers and cannot be changed in Setup Python App.

Why is my Python app returning a 500 error?

Check stderr.log inside your application root folder for details. LiteSpeed writes all unhandled Python tracebacks and WSGI startup failures to that file.

How do I install packages from requirements.txt?

Dependencies do not install automatically upon upload. Add requirements.txt under Configuration files in Setup Python App, press Enter, and click Run Pip Install.

How do I run Django database migrations?

Run migrations over SSH. Activate your virtual environment with the command shown inside Setup Python App, then run python manage.py migrate from your project root.

CAN'T FIND IT?

Real humans answer fast.

Hosting with us? Open a ticket and a real person replies - no scripts, no upsells. Still choosing a host? The same team is included with every plan, from day one.