gpt4 book ai didi

python - 让 App Engine 模块工作

转载 作者:行者123 更新时间:2023-11-28 16:37:16 25 4
gpt4 key购买 nike

我正在学习 Google App Engine 模块,但我似乎无法让它们在 dev_appserver 上运行,甚至无法通过下载和使用它们的 sample application .

根据示例应用程序,所有发送到 /work/mobile 的请求都会被分派(dispatch)到相应的模块。

但是,当我向 http://localhost:8080/workhttp://localhost:8080/mobile 发送请求时,它返回 404。

我使用命令行启动 dev_appserver:

dev_appserver.py appengine-modules-helloworld-python-master

然后我得到:

INFO     2014-06-23 09:39:16,375 sdk_update_checker.py:242] Checking for updates to the SDK.
INFO 2014-06-23 09:39:16,673 sdk_update_checker.py:286] This SDK release is newer than the advertised release.
WARNING 2014-06-23 09:39:16,678 api_server.py:378] Could not initialize images API; you are likely missing the Python "PIL" module.
INFO 2014-06-23 09:39:16,682 api_server.py:171] Starting API server at: http://localhost:61790
INFO 2014-06-23 09:39:16,686 dispatcher.py:182] Starting module "default" running at: http://localhost:8080
INFO 2014-06-23 09:39:16,692 admin_server.py:117] Starting admin server at: http://localhost:8000

根据文档,我应该看到更多的行告诉我其他模块正在不同的端口上启动,但由于某种原因我没有得到。

然后,如果我运行以下代码:

import webapp2
from google.appengine.api import modules

class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hello, webapp2 World!\n%s\n%s' % (modules.get_modules(), modules.get_hostname()))

APP = webapp2.WSGIApplication([('/', MainPage),], debug=True)

结果是:

Hello, webapp2 World!
['default']
localhost:8080

就好像没有加载非默认模块一样...

设置模块并使它们在本地开发服务器和生产环境中工作的正确方法是什么?

谢谢

最佳答案

您在 yaml 文件中的应用名称有误。这些名称应该与您在 dev_appserver.py 命令中启动本地服务器时使用的名称相匹配:appengine-modules-helloworld-python-master。在命令或 yaml 文件中切换它,使它们匹配。

您还需要在开发服务器中启动模块:

dev_appserver.py dispatch.yaml app.yaml mobile_frontend.yaml static_backend.yaml

关于python - 让 App Engine 模块工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24350525/

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