How to host Flask app in Cyberpanel

Hi, Cyberpanel Community

I’m trying to host Flask app from 1 week but, not able to do that. Can you please help me to host Flask app on cyberpanel. I’m also providing you what i tryied.

  1. sudo apt-get update
  2. sudo apt-get upgrade
  3. sudo apt-get install python3 python3-pip python3-venv
  4. sudo apt-get install apache2 libapache2-mod-wsgi-py3
  5. Created website in cyberpanel
  6. login through ssh with root with cd/home/sitename/public_html
  7. python3 -m venv venv
  8. source venv/bin/activate
  9. pip install Flask Gunicorn requests Flask-mail
  10. uploaded wsgi file with below content
import sys
import logging
 
sys.path.insert(0, '/home/sitename/public_html')
sys.path.insert(0, '/home/sitename/public_html/venv/lib/python3.10/site-packages/')
 
# Set up logging
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
 
# Import and run the Flask app
from app import app as application
  1. added virtual host as below
<VirtualHost *:80>
        ServerName sitename
        ServerAdmin webmaster@localhost
        DocumentRoot /home/sitename/public_html/
 
        WSGIDaemonProcess wsgifilename threads=5
        WSGIScriptAlias / /home/sitename/public_html/wsgifilename.wsgi
        WSGIApplicationGroup %{GLOBAL}
        <Directory flaskapp>
             WSGIProcessGroup flaskapp
             WSGIApplicationGroup %{GLOBAL}
             Order deny,allow
             Allow from all
        </Directory>
 
        ErrorLog ${APACHE_LOG_DIR}/flaskapp-error.log
        CustomLog ${APACHE_LOG_DIR}/flaskapp-access.log combined
</VirtualHost>
  1. sudo a2ensite sitename
  2. sudo service apache2 restart

But, I’m getting 404 error. Can you help me to host flask app on cyberpanel properly. Can you please provide a guide to host flask app on cyberpanel.

1 Like

Hello you know i had similar issue . I cant run flask under Port 80 ir 443. I change the config un virtual host but doesnt work