From fd91c27a3998d9c86a53564b14cdf23c4b0b1c41 Mon Sep 17 00:00:00 2001 From: baskayj Date: Tue, 21 Dec 2021 19:14:04 +0100 Subject: [PATCH] Update 'Quick Guide to publishing websites on hal.elte.hu with Python3 backend' --- ...tes-on-hal.elte.hu-with-Python3-backend.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Quick-Guide-to-publishing-websites-on-hal.elte.hu-with-Python3-backend.md b/Quick-Guide-to-publishing-websites-on-hal.elte.hu-with-Python3-backend.md index 0ce7733..d9306c0 100644 --- a/Quick-Guide-to-publishing-websites-on-hal.elte.hu-with-Python3-backend.md +++ b/Quick-Guide-to-publishing-websites-on-hal.elte.hu-with-Python3-backend.md @@ -24,7 +24,6 @@ Since Flask’s built-in server is not fit for live traffic, you need another WS 2. Install **mod_wsgi** compiled with python3: `SUDO APT-GET INSTALL LIBAPACHE2-MOD-WSGI-PY3` 3. Enable mod_wsgi: `SUDO A2ENMOD WSGI` 4. Create a config file for your website: - #### Creating `your_app.conf` This file contains the paths to all the important Files needed for Apache2 to run your Python3 scripts. The minimal config file for a Flask-app, with static files (Images, CSS) present looks like: ``` @@ -67,4 +66,20 @@ Replace `your_app` with the appropriate name of your website and folders. If you > |-------------------------main.py > |------------------------- (…) -7. ASD +7. Create a wsgi script, that can start your Python app in your virtualenv: +#### Creating `your_app.wsgi` +``` +#!/var/www/html/your_app/your_app/venv/bin/python +import sys +import logging +import os + +APP_HOME = "/var/www/html/your_app/your_app/" +sys.path.insert(0,"/var/www/html/your_app/your_app/venv/lib/python3.9/site-packages") + +logging.basicConfig(stream=sys.stderr) +sys.path.insert(0,APP_HOME) +os.chdir(APP_HOME) + +from main import app as application +```