Navigate to "Sites" and create a new website and choose the "Extended settings" while setting up the website. Select the "Handler" with the option "Path to server" and "Connection method". The "server.py" file and the "Port" are given as an example. Click "Create".
In the site's settings, find the port number. Use this port number for server arguments. For the instance, "runserver 20000". Click "Save".
Open the site's directory in the "Website files" or "File manager" menu. Create the file "passenger_wsgi.py".
Clean up the "server.py" file and add following code into the file:
from flask import Flaskapplication = Flask(__name__)@application.route("/")def hello():return "<h1 style='color:blue'>Hello There!</h1>"if __name__ == "__main__":application.run(host='0.0.0.0', port=20000)
Set your own values for "host" and "port" parameters. Default values are "0.0.0.0" and "20000" respectively.
Then edit the file "passenger_wsgi.py":
import sysimport osINTERP = os.path.expanduser("/var/www/<user>/data/www/<website>/.venv/bin/<python>")if sys.executable != INTERP:os.execl(INTERP, INTERP, *sys.argv)sys.path.append(os.getcwd())from hello import application
In the "os.path.expanduser" parameter set your own values for "<user>" (owner of the website), "<website>" (name of the website) and "<python>" (Python interpreter version, e.g. "python3.12").
You can see the path to Python interpreter in the site's settings.
Navigate to the "Browsing Python packages" in the right side menu and install Flask.
this is outdated