Gunicorn fails to start flask server with the error: Failed to find attribute 'app' in 'wsgi'.
.
The wsgi.py
#!/usr/bin/python3
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/root/customer-account-automation/")
from app import app as application
if __name__ == "__main__":
application.run()
app.py
#!/usr/bin/python3
from flask import Flask
app = Flask(__name__)
...
Project structure:
(customer-account-automation) root@jsd-user-management:~/customer-account-automation# tree
.
├── Pipfile
├── Pipfile.lock
├── README.md
├── __pycache__
│ ├── app.cpython-37.pyc
│ └── wsgi.cpython-37.pyc
├── app.py
├── customerAccountMgmt.py
├── get-pip.py
├── static
│ ├── app.js
│ ├── bulma.min.css
│ ├── highlight.min.css
│ ├── highlight.min.js
│ └── styles.css
├── templates
│ ├── 404.html
│ ├── base.html
│ ├── change_password.html
│ ├── create_user.html
│ ├── deactivate_user.html
│ └── login.html
└── wsgi.py
I checked (Gunicorn can't find app when name changed from "application") but it doesn't relate to mine as I already use the application
.
Any ideas what could be the problem?
gunicorn your.wsgi:yourappname
where you put :yourappname to be the app instance you create in your code – Prgunicorn wsgi:app
instead ofgunicorn wsgi
I guess - the later one will use default instance name as application – Pr