Gunicorn无法启动烧瓶服务器,并显示错误:Failed to find attribute 'app' in 'wsgi'.
。
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__)
...
项目结构:
(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
我检查了(Gunicorn can't find app when name changed from "application"),但它与我的无关,因为我已经使用了application
。
任何想法可能是什么问题?
答案 0 :(得分:0)
Gunicorn正在wsgi中寻找应用,因此请更改
from app import app as application
if __name__ == "__main__":
application.run()
到
from app import app as application
app = application
然后您可以运行do ...这就是我想您正在执行的
gunicorn <all the options here> wsgi:app