我尝试使用云点来构建我的API(在本地服务器上)。 但我现在遇到了一些问题。我在helloworld.py上添加了云端点代码,如下所示:
class StringMsg(messages.Message):
"""Greeting that stores a message."""
msg = messages.StringField(1)
class SringListMsg(messages.Message):
"""Collection of Greetings."""
items = messages.StringField(1, repeated=True)
@endpoints.api(name='test', version='v3', description="FIRST")
class test(remote.Service):
@endpoints.method(
StringMsg,
SringListMsg
)
# path='test',
# http_method='GET',
# name='test')
def test(self, request):
msg = request.msg
splitted = msg.split()
return SringListMsg(items=splitted)
api = endpoints.api_server([test])
根据Google的文档,云终端必须是app.yaml。所以,我把它放在我的app.yaml上,就像这样:
application: blabla
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /_ah/spi/.*
script: helloworld_api.api
- url: /.*
script: main.app
libraries:
- name: webapp2
version: latest
- name: jinja2
version: latest
- name: pycrypto
version: "2.6"
- name: endpoints
version: 1.0
现在,在我的情况下,我需要启动三个模块,所以我使用
dev_appserver.py app.yaml dispatch.yaml backend.yaml frontmodule.yaml
我去了
localhost:8080/_ah/api/explorer
我没有看到我的API,但我收到错误:
Skipping dispatch.yaml rules because /_ah/api/explorer is not a dispatcher path
但我在我的dispatch.yaml上添加/ _ah / api / explorer。 请有人帮帮我!!!