[英]Problem with Procfile / wsgi when deploying to heroku with python flask app ~ Failed to find attribute
[英]Gunicorn: Failed to find attribute 'app' in 'wsgi' when attempting to start flask server
Gunicorn 无法启动 flask 服务器并出现错误: 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()
应用程序.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 找不到应用程序)但它与我的无关,因为我已经使用了该application
。
任何想法可能是什么问题?
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.