def greetings_multiply(self, request): return Greeting(message=request.message * request.times)
def post(self): name = self.request.get('name') age = int(self.request.get('age')) content = self.request.get('content') greeting = Greeting(name=name, age=age, content=content) greeting.put() self.redirect('/')
"""Hello World API implemented using Google Cloud Endpoints. Defined here are the ProtoRPC messages needed to define Schemas for methods as well as those methods defined in an API. """ import endpoints from protorpc import messages from protorpc import message_types from protorpc import remote from models.greeting import Greeting from models.greeting_collection import GreetingCollection STORED_GREETINGS = GreetingCollection(items=[ Greeting(message='hello world!'), Greeting(message='goodbye world!'), ]) hw_api = endpoints.api(name='helloworld', version='v1') @hw_api.api_class(resource_name='helloworld') 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