我对 Python 和 Google AppEngine 还很陌生,但有大约 7 年的编程经验。我也是 StackOverflow 的新手。
我一直在尝试为我的个人项目设置一个简单的 Google Cloud Endpoint API,并已完成并将完成的应用程序上传到 Google App Engine。
这是我的端点 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 看起来像:
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"
最后 services.py 内容如下:
from google.appengine.ext import endpoints
from 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/ 访问 API Explorer 时,列表中的服务为空,在 JavaScript 控制台中,我在 https:// my-app-name .appspot.com/_ah/api/discovery/v1/apis 上看到 404 错误。
在本地测试服务器上点击这些 URL 会产生完全不同的错误。当我尝试在 localhost:8080/_ah/api/discovery/v1/apis 访问本地测试服务器上的 API Discovery 时,我得到了
{“错误”:{“消息”:“BackendService.getApiConfigs 错误”}}
而不是“未找到”。在https://developers.google.com/apis-explorer/?base=http://localhost:8080/_ah/api#p/中点击资源管理器现在也会在 JavaScript 控制台中显示 500 错误而不是 404。
我一直在尝试通过进行许多 Google 搜索并尝试很多事情来解决这个问题,但我似乎无法继续进行下去。我非常感谢我能从这个专业人士社区获得的任何帮助。
谢谢。