Appengine模块:使用dispatch.yaml不工作的路由 [英] Appengine module: Routing with dispatch.yaml not working
问题描述
我正在使用模块,但是我无法按照这里的说明工作路由 https://developers.google.com/appengine/docs/python/modules/routing
I'm using modules, but i cannot put to work the routing as explanined here https://developers.google.com/appengine/docs/python/modules/routing
更新:
appcfg.py update dispatch.yaml app.yaml comunapp_site.yaml
appcfg.py update_dispatch
端点api按预期工作,但该网站没有
i预计此功能可用
the endpoint api works as expected but the site doesn't i expected this to work
https://skilled-cargo-111.appspot.com/comunapp/
但只有这样才行
but only this works
https://comunapp-dot-skilled-cargo-111.appspot.com/
这是我的yaml文件:
Here are my yaml file:
app.yaml
app.yaml
application: skilled-cargo-111
module: default
version: 1
runtime: python27
api_version: 1
threadsafe: yes
automatic_scaling:
min_idle_instances: 1
max_pending_latency: 3s
handlers:
- url: /_ah/spi/.*
script: mobile_api.application
libraries:
- name: endpoints
version: 1.0
comunapp_site.yaml
comunapp_site.yaml
application: skilled-cargo-111
module: comunapp
version: 1
runtime: python27
api_version: 1
threadsafe: yes
automatic_scaling:
min_idle_instances: 1
max_pending_latency: 10s
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /css
static_dir: css
- url: /bootstrap
static_dir: bootstrap
- url: /images
static_dir: images
- url: /javascript
static_dir: javascript
#- url: /login.*
# script: "main.py"
# secure: always
- url: /.*
script: comunapp_site.app
login: optional
secure: always
libraries:
- name: webapp2
version: "2.5.2"
- name: jinja2
version: latest
dispatch.yaml
dispatch.yaml
application: skilled-cargo-111
dispatch:
- url: "*/favicon.ico"
module: default
- url: "*/comunapp/*"
module: comunapp
- url: "*/api/*"
module: default
推荐答案
发生的事情是您的调度文件表示路由任何请求to hostname / comunapp / * 添加到您的 comunapp 处理程序中,但获取该处理程序的URL的类型为 skilled-cargo-111.appspot.com/comunapp / ,而您可能只设置 / 路径的处理程序,就像您对默认模块所做的那样。
What's happening is that your dispatch file says to route any request coming to hostname/comunapp/* to your comunapp handler, but the URL getting to that handler is of the type skilled-cargo-111.appspot.com/comunapp/, while you probably only set up the handler for the / path, as you did with the default module.
您正在使用Python,请尝试将您的代码更新为以下内容:
If you're using Python, try updating your code to something like:
comunapp = webapp2.WSGIApplication([
('/comunapp/*', ComunApp),
], debug=True)
它应该做到这一点。
对于api路径,您应该添加/ api /处理程序在默认的模块代码中。
Also for the "api" path, you should add the "/api/" handler in the default module code.
您可以通过在开发人员控制台中检查comunapp模块的日志来检查分派文件是否正常工作。如果您看到/ comunapp / * URL的请求,但得到一个404错误是我之前提到的。如果您没有看到comunapp模块日志中出现的任何URL,那么派发文件是解决问题的关键。
You could check if dispatch file is working correctly by checking the logs for the comunapp module in the Developers' Console. If you see the requests for /comunapp/* URLs but get a 404 error is what I mentioned earlier. If you wouldn't see anything of those URLs appearing in the comunapp module logs, then the dispatch file is the key to solve the issue.
这篇关于Appengine模块:使用dispatch.yaml不工作的路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!