Flask installation in ispmanager 6
Why?
Setting up Flask framework on a website in ispmanager 6.
Instructions
In the "Settings" menu, navigate to "Software configuration". Install "Python".
![](https://static.ispmanager.com/knowledge-base/2024/06/12/G5eRAW6GK8pVqsKrGlRCfeMdbGDuAQEknxh5UJYd.png)
In the user's settings, enable "Can use Python" and "Shell access" options. Click "Save".
![](https://static.ispmanager.com/knowledge-base/2024/06/12/QGHx8lK5fKrwzkNFro1PmkA3zmOKL73uX1BLuoI4.png)
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".
![](https://static.ispmanager.com/knowledge-base/2024/06/12/BJHu0N03citczz2NDcecyn3COj0ENW7gck1qoOjI.png)
![](https://static.ispmanager.com/knowledge-base/2024/06/12/eFqVsOmWHOnXZ7FjGSSQXr8vKdOL4sKuxcswoZ9Q.png)
In the site's settings, find the port number. Use this port number for server arguments. For the instance, "runserver 20000". Click "Save".
![](https://static.ispmanager.com/knowledge-base/2024/06/12/Ldhr16yzuwyAdAsHVUMkI2PWTAPMFBSy4hxHOo2Y.png)
Open the site's directory in the "Website files" or "File manager" menu. Create the file "passenger_wsgi.py".
![](https://static.ispmanager.com/knowledge-base/2024/06/12/CoiSYAgkQQGtol606HAvnoK09rFmqPZ34EXVXzMY.png)
Clean up the "server.py" file 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 "host" and "port" parameters. Default values are "0.0.0.0" and "20000" respectively.
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.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.
![](https://static.ispmanager.com/knowledge-base/2024/06/12/U3rQZ7sjxVXMkJWZZlBW6dDWXLec4UxQBhvgoEYc.png)
Navigate to the "Browsing Python packages" in the right side menu and install Flask.
![](https://static.ispmanager.com/knowledge-base/2024/06/12/m7kuaaYXXDCrxb2nwerjnxNAULTlqhquYeaqMXUi.png)
![](https://static.ispmanager.com/knowledge-base/2024/06/12/zYdCPLJ380GVY5hUhtJWl8wbIuFenTqykQjoX3Xn.png)
![](https://static.ispmanager.com/knowledge-base/2024/06/12/5VRy3RiqDQW0jKixbw6T3InTUfOlyAmLHFJjuOqk.png)
The dependencies are set automatically. See details in the file "requirements.txt".
You can also create new in the file "requirements.txt" and click "Pip install" on the right side menu.
As an example, "python-dotenv" and "watchdog" will not be installed automatically. But Flask will detect and use them.
Now the Flask is available at your website!