python - Gunicorn:尝试启动 Flask 服务器时无法在 'app' 中找到属性 'wsgi'

标签 python flask gunicorn

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()
应用程序
#!/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 .
任何想法可能是什么问题?

最佳答案

Gunicorn 正在 wsgi 中寻找应用程序所以改变

from app import app as application
if __name__ == "__main__":
    application.run()
from app import app as application
app = application
然后你可以跑做...这就是我猜你在做什么
gunicorn <all the options here> wsgi:app

关于python - Gunicorn:尝试启动 Flask 服务器时无法在 'app' 中找到属性 'wsgi',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62799115/

相关文章:

python - Tensorflow 2.0 - 这些模型预测代表概率吗?

python - 如何创建一个组合嵌套在元组中的列表值的索引?

python - TensorFlow 中图形集合的目的是什么?

生产中使用 Flask 的静态文件

django - 在新的 ssh session 中控制 Gunicorn

django - 502 错误 django + nginx + gunicorn - connect() recv()

python - 简单的 python 代码不起作用

javascript - 刷新页面 Ajax Flask Web 应用程序

python - 将Python中的字符串作为变量传递给Flask中的render_template()

gunicorn 启动后无法访问 Django 站点