Python 2.7 当Google云端点服务器试图与其通信时,应用程序返回了一个错误
嗨,我是谷歌应用引擎和云端点的新手 我有一个服务于web应用程序的应用程序引擎 我想将它用于云端点 所以我只是在这里添加了源代码: 但我无法部署应用程序并获取以下错误消息:Python 2.7 当Google云端点服务器试图与其通信时,应用程序返回了一个错误,python-2.7,google-app-engine,google-cloud-endpoints,Python 2.7,Google App Engine,Google Cloud Endpoints,嗨,我是谷歌应用引擎和云端点的新手 我有一个服务于web应用程序的应用程序引擎 我想将它用于云端点 所以我只是在这里添加了源代码: 但我无法部署应用程序并获取以下错误消息: Checking if Endpoints configuration has been updated. 07:13 AM Failed to update Endpoints configuration. The app returned an error when the Google Cloud Endpoint
Checking if Endpoints configuration has been updated.
07:13 AM Failed to update Endpoints configuration. The app returned an error when the Google Cloud Endpoints server attempted to communicate with it.
07:13 AM See the deployment troubleshooting documentation for more information: https://developers.google.com/appengine/docs/python/endpoints/test_deploy#troubleshooting_a_deployment_failure
这是我的源代码
import endpoints
from protorpc import messages
from protorpc import message_types
from protorpc import remote
package = 'Hello'
class Greeting(messages.Message):
"""Greeting that stores a message."""
message = messages.StringField(1)
class GreetingCollection(messages.Message):
"""Collection of Greetings."""
items = messages.MessageField(Greeting, 1, repeated=True)
STORED_GREETINGS = GreetingCollection(items=[
Greeting(message='hello world!'),
Greeting(message='goodbye world!'),
])
@endpoints.api(name='helloworld', version='v1')
class HelloWorldApi(remote.Service):
"""Helloworld API v1."""
@endpoints.method(message_types.VoidMessage, GreetingCollection,
path='hellogreeting', http_method='GET',
name='greetings.listGreeting')
def greetings_list(self, unused_request):
return STORED_GREETINGS
ID_RESOURCE = endpoints.ResourceContainer(
message_types.VoidMessage,
id=messages.IntegerField(1, variant=messages.Variant.INT32))
@endpoints.method(ID_RESOURCE, Greeting,
path='hellogreeting/{id}', http_method='GET',
name='greetings.getGreeting')
def greeting_get(self, request):
try:
return STORED_GREETINGS.items[request.id]
except (IndexError, TypeError):
raise endpoints.NotFoundException('Greeting %s not found.' %
(request.id,))
APPLICATION = endpoints.api_server([HelloWorldApi])
与教程完全相同
还有我的app.yaml
application: my application id
version: application version
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /data
script: MLP.app
login: admin
- url: /insert_db
script: MLP.app
login: admin
- url: /validete
script: MLP.app
login: admin
- url: /stylesheets
static_dir: stylesheets
- url: /js
static_dir: js
- url: /.*
script: MLP.app
- url: /_ah/spi/.*
script: MLP_mobile_backend.APPLICATION
libraries:
- name: webapp2
version: latest
- name: jinja2
version: latest
- name: pycrypto
version: latest
- name: endpoints
version: 1.0
py只是webapp2的web服务
如何解决问题?从
app.yaml
行脚本:MLP\u mobile\u backend.APPLICATION
,这意味着您的代码示例必须位于app engine项目根目录下的MLP\u mobile\u backend.py
文件中
.
├── app.yaml
├── MLP.py
└── MLP_mobile_backend.py
使用在该文件中定义的名为APPLICATION
的端点api服务器,就像上面的代码示例一样
APPLICATION = endpoints.api_server([HelloWorldApi])
满足这些要求后,这一行指向如何访问端点:
@endpoints.api(name='helloworld', version='v1')
例如,假设您正在端口8080上运行devserver模块,并且希望访问hellogreeting路径:
@endpoints.method(message_types.VoidMessage, GreetingCollection,
path='hellogreeting', http_method='GET',
name='greetings.listGreeting')
您可以使用或或您的浏览器在本地导航到devserver的默认模块,该模块位于或使用Google的API资源管理器,在该模块上应生成以下响应正文:
{
"items": [
{
"message": "hello world!"
},
{
"message": "goodbye world!"
}
]
}
一旦在本地设置了它,就可以部署它
在部署之前,您能在本地测试它吗?我可以在本地启动程序。。。但我找不到教程中提到的任何带有helloapi的API名称