Python 谷歌应用引擎模块:对路由感到困惑(dispatch.yaml)
[在深入研究这个问题之后,问题似乎不是关于路由,而是关于在模块中使用端点。新问题在 我正在将一个GAE应用程序迁移到模块,我对路由感到困惑,因为有些查询路由正确,但不是所有查询都正确 我的根文件夹中有以下dispatch.yamlPython 谷歌应用引擎模块:对路由感到困惑(dispatch.yaml),python,google-app-engine,dispatch,Python,Google App Engine,Dispatch,[在深入研究这个问题之后,问题似乎不是关于路由,而是关于在模块中使用端点。新问题在 我正在将一个GAE应用程序迁移到模块,我对路由感到困惑,因为有些查询路由正确,但不是所有查询都正确 我的根文件夹中有以下dispatch.yaml application: testapp dispatch: - url: "*/foo/*" module: foomodule - url: "*/_ah/spi/*" module: api - url: "testapp.apps
application: testapp
dispatch:
- url: "*/foo/*"
module: foomodule
- url: "*/_ah/spi/*"
module: api
- url: "testapp.appspot.com/"
module: default
然后按模块名创建一个文件夹,每个文件夹都有一个yaml文件,用处理程序定义URL模式,例如,我的默认模块为/www/www.yaml
application: testapp
version: alpha
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /static
static_dir: static
- url: /.*
script: www.app
libraries:
- name: webapp2
version: latest
诸如/foo/xxx之类的查询被正确重定向到默认值,/foo/xxx由foomodule处理,但是API请求(/\u ah/spi/xxx)将通过404发送到默认模块
但是,我可以在映射到api模块的实例日志中看到200 OK for/_ah/spi/BackendService.logMessages。这条消息来自alpha-dot-api-dot-testapp.appspot.com,而404只来自testapp.appspot.com。(注意:我想让我的查询在testapp.appspot.com上运行)
有什么我做错了吗?还有,有没有办法列出服务器上当前使用的配置,以确保其正确部署?很容易将端点api分解到单独的模块中,并使用dispatch.yaml来设置路由,但使用dev_appserver.py,您似乎无法做到这一点。根据代码:
任何以
/\u ah/
开头的路径都不是可调度的路径。在api yaml文件中是否有-url:/\u ah/spi/
处理程序?是的,我有处理程序:-url:/\u ah/spi/*脚本:myapi.app是否运行:appcfg.py update dispatch.yaml www.yaml api.yaml foo.yaml
?在api.yaml中是否有模块:apide>?api模块上是否有任何打开的实例运行?如果有,则它们有陈旧的代码-杀死它们,再试一次。@GAEfan-是的,我在api/api.yamp中有模块引用。我已经运行了appcfg.py update www/www.yaml upload/upload.yaml api/api.yaml;appcfg.py update\u dispatch。但仍然是相同的错误。即使杀死实例之后s、 在从API控制台/资源管理器调用API时,也可以使用404。
if (not path.startswith('/_ah/') or
any(path.startswith(wl) for wl
in DISPATCH_AH_URL_PATH_PREFIX_WHITELIST)):
return True
else:
logging.warning('Skipping dispatch.yaml rules because %s is not a '
'dispatchable path.', path)
return False