Skip to main content
 首页 » 编程设计

python之Flask 应用程序不会像 wsgi 一样重新启动扭曲的 16.4.X

2025年04月02日9bhlsheji

我有简单的 Flask 应用程序 test.py:

from flask import Flask 
 
app = Flask(__name__) 
 
@app.route('/') 
def test(): 
    return 'Hello world!' 
 
if __name__ == '__main__': 
    app.run() 

运行扭曲的 16.3.0 工作正常:

twistd -n web --port 5000 --wsgi test.app 

升级到 16.4.0 后,我在启动时遇到错误:

No such WSGI application: 'test.app' 

什么意思?

请您参考如下方法:

您可能会选择 test 模块,它是 Python 标准库的一部分。将您的代码文件(模块)重命名为其他名称。您可能还需要设置 PYTHONPATH,以便它在代码模块所在的目录中查找。