flask app doesn't run apache2. SyntaxError: invalid syntax
I run my flask app into python virtual environment and wanted to run production wsgi server. I follow this I setting apache2 + mod_wsgi. I create my .wsgi
file with this:
#! /var/www/azure/azure/venv/bin/python3.8 import logging import sys logging.basicConfig(stream=sys.stderr) # Virtualenv Settings activate_this = '/var/www/azure/azure/venv/bin/activate_this.py' with open(activate_this) as file_: exec(file_.read(), dict(__file__=activate_this)) # Add this file path to sys.path in order to import settings sys.path.insert(0, '/var/www/azure/azure') # Add this file path to sys.path in order to import app # sys.path.append('/var/www/azure/azure/venv/lib/python3.8/site-packages') # Create appilcation for our app from app import app as application
and create /etc/apache2/sites-available
config with:
<VirtualHost *:80> ServerName 127.0.0.1 WSGIScriptAlias / /var/www/azure/azure/azure.wsgi WSGIDaemonProcess azure python-path=/var/www/azure/azure/venv/lib/python3.8/site-packages Alias /azure /var/www/azure/azure <Directory /var/www/azure/azure/> WSGIScriptReloading On WSGIProcessGroup azure WSGIApplicationGroup %{GLOBAL} Order deny,allow Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
But when I try to go to my apache page I got error
internal server error
Sure I checked /var/log/apache2/error.log
I seen this:
[Wed Jul 15 00:10:17.346375 2020] [wsgi:error] [pid 160391] [client 127.0.0.1:43990] mod_wsgi (pid=160391): Failed to exec Python script file '/var/www/azure/azure/azure.wsgi'. [Wed Jul 15 00:10:17.346479 2020] [wsgi:error] [pid 160391] [client 127.0.0.1:43990] mod_wsgi (pid=160391): Exception occurred processing WSGI script '/var/www/azure/azure/azure.wsgi'. [Wed Jul 15 00:10:17.346513 2020] [wsgi:error] [pid 160391] [client 127.0.0.1:43990] Traceback (most recent call last): [Wed Jul 15 00:10:17.346550 2020] [wsgi:error] [pid 160391] [client 127.0.0.1:43990] File "/var/www/azure/azure/azure.wsgi", line 21, in <module> [Wed Jul 15 00:10:17.346644 2020] [wsgi:error] [pid 160391] [client 127.0.0.1:43990] from app import app as application [Wed Jul 15 00:10:17.346720 2020] [wsgi:error] [pid 160391] [client 127.0.0.1:43990] File "/var/www/azure/azure/app.py", line 38 [Wed Jul 15 00:10:17.346733 2020] [wsgi:error] [pid 160391] [client 127.0.0.1:43990] file_html = f"{page_id}.html" [Wed Jul 15 00:10:17.346743 2020] [wsgi:error] [pid 160391] [client 127.0.0.1:43990] ^ [Wed Jul 15 00:10:17.346753 2020] [wsgi:error] [pid 160391] [client 127.0.0.1:43990] SyntaxError: invalid syntax
Also, I try to use different python version but nothing changes I use Ubuntu 20.04 My python version is 3.8 Apache 2.4
please could you give me any tuning advice? I also tried reinstalling all dependency packages and the virtual environment. I have no idea left
PS/ I’m sorry there is my app directory three my app directory three