gpt4 book ai didi

python-3.x - 错误: Bad Gateway 502 when opening Google App Engine Python Domain

转载 作者:行者123 更新时间:2023-12-02 01:06:57 25 4
gpt4 key购买 nike

当我访问我的网站 ( https://osm-messaging-platform.appspot.com ) 时,我在主网页上收到此错误:

502 Bad Gateway. nginx/1.14.0 (Ubuntu).

这真的很奇怪,因为当我在本地运行它时

python app.py

我没有收到任何错误,并且我的应用程序和网站加载正常。

我已经尝试查找它,但我在堆栈溢出上找到的大多数答案要么没有错误,要么与我无关。这是我查看 GCloud 日志时出现的错误:

019-02-07 02:07:05 default[20190206t175104]  Traceback (most recent 
call last): File "/env/lib/python3.7/site-
packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process() File "/env/lib/python3.7/site-
packages/gunicorn/workers/gthread.py", line 104, in init_process
super(ThreadWorker, self).init_process() File
"/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line
129, in init_process self.load_wsgi() File
"/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line
138, in load_wsgi self.wsgi = self.app.wsgi() File
"/env/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in
wsgi self.callable = self.load() File
"/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52,
in load return self.load_wsgiapp() File
"/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41,
in load_wsgiapp return util.import_app(self.app_uri) File
"/env/lib/python3.7/site-packages/gunicorn/util.py", line 350, in
import_app __import__(module) ModuleNotFoundError: No module
named 'main'
2019-02-07 02:07:05 default[20190206t175104] [2019-02-07 02:07:05
+0000] [25] [INFO] Worker exiting (pid: 25)
2019-02-07 02:07:05 default[20190206t175104] [2019-02-07 02:07:05
+0000] [8] [INFO] Shutting down: Master
2019-02-07 02:07:05 default[20190206t175104] [2019-02-07 02:07:05
+0000] [8] [INFO] Reason: Worker failed to boot.

这是我的 app.yaml 文件的内容:

runtime: python37

handlers:
# This configures Google App Engine to serve the files in the app's
static
# directory.
- url: /static
static_dir: static


- url: /.*
script: auto

我希望它能显示我的网站,但它没有。有人可以帮忙吗?

最佳答案

产生该错误的原因是 App Engine 标准 Python37 运行时默认处理 main.py 文件中的请求。我猜您没有此文件,并且您正在 app.py 文件中处理请求。

日志回溯也指向它:ModuleNotFoundError:没有名为“main”的模块

app.py 文件的名称更改为 main.py 并重试。

作为一般规则,建议遵循App Engine Standard documention中存在的文件结构。 :

  • 你的应用程序/
    • app.yaml
    • main.py
    • requirements.txt
    • 静态/
      • script.js
      • style.css
    • 模板/
      • index.html


我相信这对于您的情况来说有点过分了,但如果您需要自定义 entrypoint阅读 his Python3 runtime documentation了解有关如何配置它的更多信息。

关于python-3.x - 错误: Bad Gateway 502 when opening Google App Engine Python Domain,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54565417/

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