Get a free website with any plan

See how
HOSTING

Deploying a Python app (Flask or Django)

IN SHORT

Flashcloud runs Python apps (Flask, Django, or plain WSGI) through cPanel's Setup Python App tool. It creates an isolated virtual environment, generates a passenger_wsgi.py entry file, and connects your app to the web server, so you never manage a process manager or reverse proxy yourself.

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 won't my Python app start?

Usually one of three things: passenger_wsgi.py isn't exposing something named application, requirements.txt got installed into the wrong virtualenv, or the application root doesn't point straight at the folder containing passenger_wsgi.py. Check your app's own error log in cPanel too, most Flask and Django startup failures show up there first.

How do I connect my Flask app to passenger_wsgi.py?

cPanel generates the file for you, but it needs to import your app object as application. For a minimal Flask app that's usually from myapp import app as application, and if your app object has a different name, alias it in that import rather than renaming it in your code.

Why isn't my code change showing up after I deployed it?

Passenger-based apps don't reload automatically. Go to Setup Python App and click Restart on the app, or touch tmp/restart.txt in your application root if your setup uses that convention. A stale process is the first thing to check when a working app suddenly throws errors.

Where do I install requirements.txt for my Django or Flask app?

Always install into the virtualenv Setup Python App created for that specific app, never a system-wide Python. You can point Setup Python App's requirements field at the file and run the install there, or activate the virtualenv over SSH and run pip install -r requirements.txt.

Should Django or Flask serve my static files in production?

No, let the web server handle it instead. Set a static files mapping on the application's detail page in Setup Python App with a URL prefix like /static and the local folder it maps to, and for Django, run python manage.py collectstatic into that folder first so STATIC_ROOT has something to point at.

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.