当前位置: 动力学知识库 > 问答 > 编程问答 >

python 2.7 - How to use cloud endpoints with multi module?

问题描述:

I'm trying to use cloud points to build my API(at local server).

But I meet some problem now. I add the cloud endpoints code at helloworld.py , like this:

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])

According to Google's document, cloud endpoints have to be app.yaml. So, I put it at my app.yaml, like this:

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

NOW, in my case I need to start three modules, so I use

dev_appserver.py app.yaml dispatch.yaml backend.yaml frontmodule.yaml

And I go to

localhost:8080/_ah/api/explorer

I did't see my API, and I get error:

Skipping dispatch.yaml rules because /_ah/api/explorer is not a dispatcher path

But I DIDN'T add /_ah/api/explorer at my dispatch.yaml.

Somebody help me please!!!

分享给朋友:
您可能感兴趣的文章:
随机阅读: