I am currently working on a backend for my website so that people don't finally see a NAME_NOT_RESOLVED error. I am using apache2 for my framework & WSGI to be able to communicate with flask, here are the files listed in my project folder located at /var/www/aviance/aviance. aviance.py aviance.wsgi __init__.py init.py __pycache__ requirements.txt static templates venv
When I finished coding my backend for the project, I keep getting an error with wsgi. Here is my code for the server.
from flask import Flask
app = Flask(__name__)
@app.route('/')
def home():
return("The API grants nothing.")
if __name__ == "__main__":
appFlask.run(debug=True)
& here is my aviance.wsgi file:
page.import logging
import sys
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0, './')
from aviance import app as application
application.secret_key = '123'
as well as my apache.conf file:
<VirtualHost *:80>
# Add machine's IP address (use ifconfig command)
ServerName 192.168.0.31
# Give an alias to to start your website url with
WSGIScriptAlias / var/www/aviance/aviance/aviance.wsgi
<Directory var/www/aviance/aviance>
# set permissions as per apache2.conf file
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
When running apache2, I keep getting this error.
[Mon Sep 26 02:44:51.416397 2022] [mpm_event:notice] [pid 10082:tid 140465239119744] AH00489: Apache/2.4.52 (Ubuntu) mod_wsgi/4.9.0 Python/3.10 configured -- resuming normal operations
[Mon Sep 26 02:44:51.416603 2022] [core:notice] [pid 10082:tid 140465239119744] AH00094: Command line: '/usr/sbin/apache2'
[Mon Sep 26 02:44:56.899802 2022] [wsgi:error] [pid 10083:tid 140465217443392] [client 192.168.0.21:5113] mod_wsgi (pid=10083): Failed to exec Python script file '/var/www/aviance/aviance/>
[Mon Sep 26 02:44:56.899883 2022] [wsgi:error] [pid 10083:tid 140465217443392] [client 192.168.0.21:5113] mod_wsgi (pid=10083): Exception occurred processing WSGI script '/var/www/aviance/>
[Mon Sep 26 02:44:56.909981 2022] [wsgi:error] [pid 10083:tid 140465217443392] [client 192.168.0.21:5113] Traceback (most recent call last):
[Mon Sep 26 02:44:56.910049 2022] [wsgi:error] [pid 10083:tid 140465217443392] [client 192.168.0.21:5113] File "/var/www/aviance/aviance/wsgi.py", line 3, in <module>
[Mon Sep 26 02:44:56.910062 2022] [wsgi:error] [pid 10083:tid 140465217443392] [client 192.168.0.21:5113] from yourapplication import app as application
[Mon Sep 26 02:44:56.910092 2022] [wsgi:error] [pid 10083:tid 140465217443392] [client 192.168.0.21:5113] ModuleNotFoundError: No module named 'aviance'
Can anyone help me identify the problem as everything looks good to me?