Here are the steps:
1. Install homebrew
https://brew.sh/
2. Install apache
brew install apache2
3. Install python
brew install python3
4. Install mod-wsgi (apache module to run scripts)
pip3 install mod-wsgi
5. Modify /opt/homebrew/etc/httpd/httpd.conf; add this (and adapt names in bold to your specific installation)
LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
LoadModule wsgi_module /opt/homebrew/lib/python3.9/site-packages/mod_wsgi/server/mod_wsgi-py39.cpython-39-darwin.so
WSGIApplicationGroup %{GLOBAL}
<Directory "/Users/wahl/Development/excel_ws">
Options Indexes MultiViews
AllowOverride none
Require all granted
</Directory>
WSGIScriptAlias /excel_ws /Users/wahl/Development/excel_ws/WebService.wsgi
assuming that the Flask application resides in /Users/wahl/Development/excel_ws and that the relative URL is /excel_ws.
6. Create the .wsgi file - this is a short python script that launches flask (in the example above, it is called WebService.wsgi residing in our flask application directory). We further assume that the Python source files reside in the directory src relative to the .wsgi file. The flask app is defined in src/WebService.py.
#! /usr/bin/python3
import logging
import sys
import os
logging.basicConfig(stream=sys.stderr)
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/src')
from WebService import app as application
application.secret_key = 'some super secret string'
No comments:
Post a Comment