a have a build a simple service based on the google endpoints API. All works fine but the Problem is the API is called from other hosts via backbone.js. So I have to allow "Access-Control-Allow-Origin: *" on server side.
But a dont find any solution in the documentation or something else. I've tried to set up this in the app.yaml like:
http_headers:
Access-Control-Allow-Origin: http://.*
but this only work for static_dir and not for scripts
Thanks for anay idea and help
from google.appengine.ext import endpoints
from google.appengine.ext import ndb
from protorpc import messages
from protorpc import message_types
from protorpc import remote
class SpotModel (ndb.Model):
description = ndb.StringProperty(required=True)
latitude = ndb.FloatProperty()
longitude = ndb.FloatProperty()
class Spot (messages.Message):
description = messages.StringField(1, required=True)
lat = messages.FloatField(2)
lng = messages.FloatField(3)
id = messages.IntegerField(4)
class SpotList (messages.Message):
items = messages.MessageField(Spot,1, repeated=True)
@endpoints.api(name="spots", version='v1',
description="API for create, update and list spots")
class SpotAPI(remote.Service):
@endpoints.method(Spot,Spot,
name='spot.insert',
path='spot',
http_method='POST')
def insertSpot(self, request):
newSpot = SpotModel(description = request.description,latitude = request.lat,longitude = request.lng)
newSpot.put()
return pareSpotToMessage(newSpot)
app = endpoints.api_server([SpotAPI])