Flask is a lightweight Python web framework that can easily run on any Python-enabled hosting plan. Here’s a clear step-by-step guide to get your Flask application live on your cPanel Python hosting.
- Log in to your cPanel account.
- Under the “Software” section, click on “Setup Python App”.
- Click the “Create Application” button.
- Choose the Python version you need (e.g., 3.9, 3.10, or higher).
- Set the Application root (this is the folder where your Flask project will live, for example: flaskapp or myproject).
- Set the Application URL (choose the domain or subdomain where the site will be accessible).
- In the “Application startup file” field, type app.py (or the exact name of your main Flask file).
- In the “Application entry point” field, type app (this is the variable name of your Flask instance, e.g., app = Flask(name)).
- Click “Save” or “Create” at the top of the page.
- Once the application is created, click the “Restart” button to start it.
- Upload your Flask project files (including app.py, requirements.txt, etc.) to the specified application root folder using File Manager or FTP.
- Open the terminal in cPanel (or via SSH) and run the following inside the virtual environment folder to install dependencies:
pip install -r requirements.txt - Your Flask site should now be running and accessible via the domain/subdomain you selected.