谷歌端点的网址处理程序中的问题

时间:2016-03-27 18:48:53

标签: google-app-engine google-cloud-endpoints

我的app.yaml

中有url处理程序
handlers:

- url: /_ah/spi/websiteapi/.*
  script: Website.application
  secure: always

但是当使用http://localhost:8080/_ah/api/websiteapi/v1/websites访问api时,我会收到错误     {       "错误":{         " message":" BackendService.getApiConfigs Error"       }     }

Help me to configure mt url handler and the below setting works fine but i need to handle several scripts depending on the url. 
- url: /_ah/spi/.*
  script: Website.application
  secure: always

1 个答案:

答案 0 :(得分:0)

App Engine上/_ah/spi的请求需要由Google Cloud Endpoints服务器处理,以便提供正确的响应。

您的脚本Website.application应该是endpoints.api_server个对象。这是一个有效的例子:

app.yaml

handlers:
- url: /_ah/spi/.*
  script: main.endpoints_app

main.py

import endpoints
import services  # Your Cloud Endpoints handlers go here.

endpoints_app = endpoints.api_server([
    services.MyService1,
    services.MyService2
])

完整文档在这里: https://cloud.google.com/appengine/docs/python/endpoints/getstarted/backend/write_api#coding_a_backend_with_a_simple_get_method