我正在学习Google App Engine模块,但似乎无法在dev_appserver上运行它们,甚至无法下载并使用其示例应用程序。
根据示例应用程序,所有发送到/work
或/mobile
将被分派到相应模块的请求。
但是,当我向http://localhost:8080/work
或发送请求时http://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
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句