由于找不到模块,pythonanywhere 上的 WSGI 配置失败

WSGI Configuration failing on pythonanywhere due to module not being found

我目前正在尝试将我的 python/flask 应用程序部署到 pythonanywhere,但目前卡在 WSGI 配置步骤。这是我的代码:

import sys
#
## The "/home/azanbade" below specifies your home
## directory -- the rest should be the directory you uploaded your Flask
## code to underneath the home directory.  So if you just ran
## "git clone git@github.com/myusername/myproject.git"
## ...or uploaded files to the directory "myproject", then you should
## specify "/home/azanbade/myproject"
path = '/home/azanbade/path/to/Word-finder'
if path not in sys.path:
    sys.path.append(path)
#
from app import app as application  # noqa
#
# NB -- many Flask guides suggest you use a file called run.py; that's
# not necessary on PythonAnywhere.  And you should make sure your code
# does *not* invoke the flask development server with app.run(), as it
# will prevent your wsgi file from working.

在我尝试 运行 应用程序之前,我觉得一切都很好。我继续收到此错误消息,“ModuleNotFoundError:没有名为 'app' 的模块”

这是我的根目录和服务器(这是我的应用程序的主文件)的照片: Root Directory, Server

我的配置格式正确吗?

您必须确保 path 指向您应用程序的正确路径。

path = '/home/<your-username>/<path-to-your-app-folder>'