How to Create a Python Application
Create a Python WSGI application such as Flask or Django from the Python Selector in the web hosting control panel on CR Servers shared hosting.
The Python Selector runs a Python web application on your domain, or on a path of it such as https://yourdomain.com/py/. It supports WSGI applications, the standard interface used by Flask, Django and similar frameworks. Each app gets its own Python environment, so its packages don't mix with other apps.
A WSGI app starts from a startup file and an entry point: the name of the WSGI object inside that file. Both must match what you enter in the selector.
Prepare your app
-
List your packages in a
requirements.txtfile. -
Add a startup file named
passenger_wsgi.pythat exposes your app asapplication. For a Flask app defined inapp.py:from app import app as applicationFor Django, point it at your project's WSGI module:
from myproject.wsgi import application
Create the application
- In the web hosting control panel, open CloudLinux → Python Selector (the cloud icon in the left menu).
- Click Create Application.
- Fill in the form:
- Python version: the list starts on Python 2.7, which is no longer supported. Change it to a current Python 3 version your app supports.
- Application root: the folder for the code, inside your home folder and outside your public website folder, for example
apps/my-python. - Application URL: pick the domain from the drop-down (it can show a placeholder label such as
[object Object]until you choose one), then type a path in the box next to it, for examplepy. - Application startup file:
passenger_wsgi.py. - Application Entry point:
application.
- Add any settings your app reads with Add Variable under Environment variables instead of putting them in files.
- Click Create.
If you leave the path empty, the app answers for the whole domain. Use a path such as py if you want to keep your current site.
Upload code and install packages
- Upload your project into the application root with the file manager or FTP.
- In the Python Selector, click the pencil icon next to the application to open it.
- Under Configuration files, type
requirements.txtin the box, click Add, then click Run Pip Install. - For Django, run one-off commands under Execute python script, using the path to
manage.pyinside your application root, for example/home/youruser/apps/my-python/manage.py migrate, and click Run Script. - Click Restart, then click Open next to the application URL and check that your app responds over HTTPS.
After each code change, upload the files and restart the app, either with Restart inside the app or the circular-arrow icon in the list. If you change a setting in the form, click Save.
Stop, start or delete
The Web Applications list shows each app's Status and Python version, with Actions icons to stop, restart, edit and delete it. The same controls are inside the app.
- Stop App (square icon in the list) takes the app offline until you start it again. Your files stay in place.
- Destroy (trash icon in the list) removes the application from the selector. It isn't the same as stopping it. Download a copy of your code first.
Good to know
- The selector runs WSGI apps. ASGI frameworks (FastAPI in async mode, Django Channels), WebSockets and long-running background workers need a VPS.
- Use the app's own environment for packages. Don't install packages for the system Python.
If it doesn't work
- Error page: check that the startup file name and the entry point match your code, then Restart.
- Missing module errors: add the package to
requirements.txt, run Run Pip Install again and restart. - Changes don't show up: restart the app after every upload.
If the selector is missing or the app still won't start, open a ticket with the domain, Python version, failing URL, approximate time and the error message (remove passwords and keys).