Black Friday

Up to 80% off web hosting and WordPress plans until 30 NovemberUp to 80% off

See plans
HOSTING

Deploying a Python app (Flask or Django)

Last updated

IN SHORT

Flashcloud runs Python applications like Flask and Django using cPanel's Setup Python App tool. It builds an isolated virtual environment and creates a passenger_wsgi.py entry file to connect your app to the web server. Your app entry file must expose a callable named application to start properly.

Python apps (Flask, Django, or plain WSGI) run on shared hosting through cPanel's Python Selector, called "Setup Python App." It creates an isolated virtual environment, generates a WSGI entry file, and wires up the passenger config that connects your app to the web server. You don't manage a separate process manager or reverse proxy yourself.

Create the application

Open cPanel from your hosting service (see Accessing cPanel if you need the way in). Find Setup Python App under Software, then:

  • Click Create Application.
  • Pick a Python version from the dropdown.
  • Set the Application root, the folder your code lives in (for example myapp, relative to your home directory).
  • Set the Application URL, the domain or subdomain the app should answer on.
  • Set the Application startup file and Application Entry point. For Flask this is usually the file that defines your app object; for Django it's the file exposing the application callable, typically wsgi.py.

Saving creates a dedicated virtual environment for the app and shows you the exact command to activate it over SSH, something like:

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

The WSGI entry point

cPanel generates a passenger_wsgi.py file in your application root. This is the file the web server actually imports, it needs to expose a callable named application. For a minimal Flask app, that often means:

from myapp import app as application

For Django, point it at your project's own wsgi.py:

from myproject.wsgi import application

If your app object is named something other than application and you can't rename it, alias it in passenger_wsgi.py rather than fighting the framework's conventions. Setup Python App scaffolds a starter version of this file when you create the app, but it's a plain Python file, so you can edit it directly once your project structure is in place.

Installing requirements.txt

Get your code onto the server before installing dependencies, either through the portal file manager, an FTP/SFTP client, or by deploying with Git. Once the files are in the application root:

  • Open Setup Python App and find your application in the list.
  • Click the pencil/edit icon to open its detail page.
  • Under the requirements section, point it at your requirements.txt and run the install, or activate the virtual environment over SSH and run:
pip install -r requirements.txt

Always install into the virtualenv Setup Python App created for this app, not a system-wide Python. Each app gets its own environment, so dependency versions for one app never collide with another.

Static files

Flask and Django both serve static assets through the Python process by default in development, but that's not the efficient path in production. In production it's better to let the web server serve static files directly and reserve the Python app for dynamic requests. Setup Python App gives you a static files mapping field on the application's detail page: set the URL prefix (for example /static) and the local folder it should map to, and the server serves those files directly. For Django, run collectstatic into that folder first:

python manage.py collectstatic

Point the static mapping at whatever STATIC_ROOT resolves to, and Django's own static file handling is bypassed for those requests entirely.

Restarting after changes

Passenger-based apps don't reload automatically when you edit code. After any change to your application files or dependencies, go back to Setup Python App and click Restart on the app, or touch the tmp/restart.txt file in your application root if your setup uses that convention. If a working app suddenly starts throwing errors after a deploy, a stale process is the first thing to rule out.

If the app won't start

  • Wrong entry point: confirm passenger_wsgi.py actually exposes something named application, and that the import path matches your real file and object names.
  • Missing dependencies: make sure requirements.txt was installed into the same virtualenv the app is configured to use, not a different Python version.
  • Application root mismatch: the root must point at the folder containing passenger_wsgi.py, not a parent or child directory.
  • Framework-level errors: check your app's own logging or the error log surfaced in cPanel. Most Flask and Django startup failures (bad imports, missing environment variables, unapplied migrations) show up there before you'd ever suspect the hosting layer.

If you've confirmed the entry point, dependencies, and application root are correct and the app still won't come up, open a ticket from Support in the portal. It's a real person looking at your specific setup, not a script.

Common questions

Why are my code changes not updating on the site?

Passenger does not reload code automatically after edits. Click Restart in Setup Python App, or touch the tmp/restart.txt file in your application root to reload the process.

How do I install my requirements.txt packages?

Install them directly into the application's dedicated virtual environment. Use the requirements section inside Setup Python App, or run pip install -r requirements.txt over SSH after activating the environment.

Why is my app crashing right after deploy?

Most startup crashes come from entry point mismatches or missing packages. Confirm that passenger_wsgi.py exports a callable named application, ensure packages are installed in the right virtual environment, and check the cPanel error log.

How do I serve static files for Django?

Route them through the web server using the static mapping tool. Run python manage.py collectstatic into your static directory, then configure that path under the static files mapping field in Setup Python App.

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.