我一直在尝试将代码部署到 GAE 上,但尝试时总是收到 500 服务器错误。
使用 Pycharm 环境我没有看到代码中的错误。有人可以帮我解决导致问题的原因吗?我还尝试使用 Postman 插件来获取 GET 和 POST 响应,但由于 500 内部服务器错误而无法这样做。 感谢您的时间和帮助。
AppEngine 日志中的错误。
Traceback (most recent call last):
File "/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 196, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 269, in _LoadHandler
raise ImportError('%s has no attribute %s' % (handler, name))
ImportError: <module 'main' from '/base/data/home/apps/s~newstartapptest/1.367182586650515795/main.py'> has no attribute app
最佳答案
在 app.yaml
中,假设上面显示的代码位于 main.py
中,您可能正在使用
script: main.app
但是您用来保存 WSGIApplication
的全局名称为 application
,而不是 app
。重命名变量。
关于python - Google App Engine 的 Python 代码出现服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16403615/