/
/
Flask installation in ispmanager 6

Flask installation in ispmanager 6

In the Settingsmenu, navigate to Software configuration. Install Python.

In the user's settings, enable Can use Pythonand Shell accessoptions. Click Save.

Navigate to Sitesand create a new website and choose the Extended settingswhile setting up the website. Select the Handlerwith the option Path to serverand Connection method. The server.py**** file and the Portare 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 filesor File managermenu. Create the file passenger_wsgi.py.

Clean up the server.pyfile and add following code into the file:

from flask import Flask
application = 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 hostand portparameters. Default values are 0.0.0.0and 20000respectively.

Then edit the file passenger_wsgi.py:

import sys
import os
INTERP = 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.expanduserparameter 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 packagesin the right side menu and install Flask.

The dependencies are set automatically. See details in the file requirements.txt.

You can also create new in the file requirements.txtand click Pip installon the right side menu.

As an example, «python-dotenv»and «watchdog»will not be installed automatically. But Flask will detect and use them.