来自 python 包的 WSGI 导入应用程序产生 500
WSGI import app from python package yields 500
我想在 apache 上部署我的 python 应用程序,所以我制作了一个 hello world 应用程序(包含在一个 python 文件中)并从那里导入了应用程序对象并且它工作了。这只是为了测试一下。
然后我将我的应用程序文件移到那里并尝试了同样的操作。我尝试导入应用程序对象(现在来自 python 包),没有任何问题,但是当我访问服务器时,我收到 500 错误代码。
注意:如果我 运行 和 python 应用程序工作正常。没坏。
文件结构:
app.wsgi main(this is the python package) hello.py(this is the simple app)
在 app.wsgi 我有这个:
import sys
sys.path.append('/var/www/html')
from hello import app as application
这行得通,但是当我将其更改为:
import sys
sys.path.append('/var/www/html')
from main import app as application
它给了我 500。
关于为什么会发生这种情况的任何想法?
显然我不得不在我的 __init__.py 文件中调用 运行。
如果有人觉得这有帮助,请保留它,否则将其删除。
我想在 apache 上部署我的 python 应用程序,所以我制作了一个 hello world 应用程序(包含在一个 python 文件中)并从那里导入了应用程序对象并且它工作了。这只是为了测试一下。
然后我将我的应用程序文件移到那里并尝试了同样的操作。我尝试导入应用程序对象(现在来自 python 包),没有任何问题,但是当我访问服务器时,我收到 500 错误代码。 注意:如果我 运行 和 python 应用程序工作正常。没坏。
文件结构:
app.wsgi main(this is the python package) hello.py(this is the simple app)
在 app.wsgi 我有这个:
import sys
sys.path.append('/var/www/html')
from hello import app as application
这行得通,但是当我将其更改为:
import sys
sys.path.append('/var/www/html')
from main import app as application
它给了我 500。
关于为什么会发生这种情况的任何想法?
显然我不得不在我的 __init__.py 文件中调用 运行。
如果有人觉得这有帮助,请保留它,否则将其删除。