AppEngine Google Cloud Endpoint - 找不到发现 [英] AppEngine Google Cloud Endpoint - discovery not found

查看:111
本文介绍了AppEngine Google Cloud Endpoint - 找不到发现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Python和Google AppEngine相当陌生,但拥有大约7年的编程经验。我也是新来的StackOverflow。



我一直在尝试为我的个人项目设置一个简单的Google Cloud Endpoint API,并完成并上传完成的应用程序Google App Engine。



以下是我的Endpoint API设置:

  @ endpoints.api(name ='puzzle',version ='v1',description ='Puzzle Engine API')

和方法:

  @ endpoints.method(
PuzzleMessage,PuzzleMessage,
name = 'puzzle.generate',
http_method ='GET',
path ='generate'


@ endpoints.method(
PuzzleMessage,PuzzleMessage ,
name ='puzzle.solve',
http_method ='GET',
path ='solve'

我的app.yaml如下所示:

 处理程序:
- url:/favicon\.ico
static_files:favicon.ico
上传:fav icon \.ico

- url:。*
脚本:main.app

#端点处理程序
- url:/ _ah / api / 。*
脚本:services.application

库:
- 名称:webapp2
版本:2.5.2

最后services.py显示:

  from google.appengine.ext从api导入端点
import puzzle_api

application = endpoints.api_server([
puzzle_api.PuzzleAPI
,restricted = False)

现在,问题是当我尝试访问https:// my-app-name .appspot.com / _ah / api / discovery / v1 / apis,我看到的只是


未找到


另外,当我在 https://developers.google.com/apis-explorer/?base=https:// my-app-name 。 Appspot上.com / _ah / api#p /,服务列表为空,并且在JavaScript控制台中,通过https:// my-app-name .appspot.com / _ah / api / discovery / v1 / apis。

在本地测试服务器上访问这些URL会导致完全不同的错误。当我尝试访问本地测试服务器上的localhost:8080 / _ah / api / discovery / v1 / apis上的API发现时,我得到


{error:{message:BackendService.getApiConfigs Error}}

而不是未找到。通过 https:/ /developers.google.com/apis-explorer/?base=http://localhost:8080/_ah/api#p/ 现在将在JavaScript控制台中显示500错误,而不是404。



我一直试图通过执行很多Google搜索来解决这个问题,并尝试了很多事情,但我似乎无法继续进行下去。我非常感谢能从这个专业人士社区获得的任何帮助。



谢谢。

解决方案

请参阅此处的文档: https://开发人员。您需要执行以下操作:

将你的app.yaml改为:

 处理程序:
- url:/favicon\.ico
static_files:favicon.ico
上传:favicon \.ico

- url:/_ah/spi/.*
script:services.application

- url:。*
script:main.app

库:
- name:webapp2
版本:2.5.2

注意:网址应该是 / _ ah / spi /.*不是 / _ ah / api /.*。改变它,然后你可以在 / _ ah / api / explorer 中访问你的api。


I am quite new to Python and Google AppEngine, but have had around 7 years of programming experience. I am also new to StackOverflow.

I've been trying to set up a simple Google Cloud Endpoint API for my personal project, and have finished and uploaded the finished app to Google App Engine.

Here are my Endpoint API settings:

@endpoints.api(name='puzzle', version='v1', description='Puzzle Engine API')

And methods:

@endpoints.method(
        PuzzleMessage, PuzzleMessage,
        name='puzzle.generate',
        http_method='GET',
        path='generate'
    )

@endpoints.method(
        PuzzleMessage, PuzzleMessage,
        name='puzzle.solve',
        http_method='GET',
        path='solve'
    )

My app.yaml looks like:

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: .*
  script: main.app

# Endpoints handler
- url: /_ah/api/.*
  script: services.application

libraries:
- name: webapp2
  version: "2.5.2"

And finally services.py reads:

from google.appengine.ext import endpoints
from api import puzzle_api

application = endpoints.api_server([
                               puzzle_api.PuzzleAPI
                           ], restricted=False)

Now, the problem is that when I try to reach https://my-app-name.appspot.com/_ah/api/discovery/v1/apis, all I see is

Not Found

Also, when I hit the API Explorer at https://developers.google.com/apis-explorer/?base=https://my-app-name.appspot.com/_ah/api#p/, the list of Services is empty, and in the JavaScript console, I see a 404 error over https://my-app-name.appspot.com/_ah/api/discovery/v1/apis.

Hitting these URLs on local test server gives quite different errors. When I try to reach the API Discovery on local test server at localhost:8080/_ah/api/discovery/v1/apis, I get

{"error": {"message": "BackendService.getApiConfigs Error"}}

instead of "Not Found". Hitting the Explorer at https://developers.google.com/apis-explorer/?base=http://localhost:8080/_ah/api#p/ would now show 500 error instead of 404 in the JavaScript console as well.

I've been trying to solve this by doing many Google Searches and trying many things out, but I just cannot seem to be able to proceed any further. I would very much appreciate any help I can get from this community of professionals.

Thanks.

解决方案

See the documentation here: https://developers.google.com/appengine/docs/python/endpoints/api_server

You need to do the following:

Change your app.yaml to:

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: /_ah/spi/.*
  script: services.application

- url: .*
  script: main.app

libraries:
- name: webapp2
  version: "2.5.2"

Note: The url should be /_ah/spi/.* not /_ah/api/.*. Change it, then you can access your api at /_ah/api/explorer.

这篇关于AppEngine Google Cloud Endpoint - 找不到发现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆