我正在学习Google App Engine模块,但我似乎无法让它们在dev_appserver上运行,甚至无法下载和使用他们的sample application。
根据示例应用程序,发送到/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
好像尚未加载非默认模块...
设置模块并使它们在本地开发服务器和生产中都能正常工作的正确方法是什么?
由于
答案 0 :(得分:3)
您在yaml文件中有错误的应用名称。名称应与您在dev_appserver.py
命令中启动本地服务器时使用的名称相匹配:appengine-modules-helloworld-python-master
。在命令或yaml文件中切换它以使它们匹配。
您还需要在开发服务器中启动模块:
dev_appserver.py dispatch.yaml app.yaml mobile_frontend.yaml static_backend.yaml