gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 11:48:43 24 4
gpt4 key购买 nike

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com