我对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 如下:
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 错误。Not Found
在本地测试服务器上访问这些 URL 会得到非常不同的错误。当我尝试访问本地测试服务器上的 API Discovery(localhost:8080/_ah/api/discovery/v1/apis)时,我得到下面的错误信息:
{"error": {"message": "BackendService.getApiConfigs Error"}}
与其显示“未找到”,现在在https://developers.google.com/apis-explorer/?base=http://localhost:8080/_ah/api#p/中访问Explorer将显示500错误,而不是JavaScript控制台中的404。
我一直在尝试通过进行许多谷歌搜索并尝试许多方法来解决这个问题,但我似乎无法进一步进行。我非常感谢这个专业社区能够提供任何帮助。
谢谢。