当我尝试在python文件上运行dev_appserver时出现以下错误。
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/yaml_listener.py", line 213, in _GenerateEventParameters
raise yaml_errors.EventListenerYAMLError(e)
google.appengine.api.yaml_errors.EventListenerYAMLError: mapping values are not allowed here
in "cfcdatastore_api.py", line 16, column 38
yaml文件
application: xxx
version: 1
runtime: python27
threadsafe: true
api_version: 1
handlers:
-url: /_ah/xxx/.*
script: cfcdatastore_api.application
libraries:
-name: endpoints
version: 1.0
python文件
import endpoints
from protorpc import messages
from protorpc import message_types
from protorpc import remote
from DatastoreEndpoints.models.NewsItem import NewsItem
from DatastoreEndpoints.models.NewsItems import NewsItems
package = "News"
STORED_MESSAGES = NewsItems(items=[
NewsItem(Title='News Item 1'),
NewsItem(Title='News Item 2')])
@endpoints.api(name='cfcdatastore', version="v1")
class CFCDatastoreApi(remote.Service):
@endpoints.method(message_types.VoidMessage, NewsItems,
path='messages', http_method='GET',
name='newsitems.listNewsitems')
def news_items_list(self, unused_request):
return STORED_MESSAGES
ID_RESOURCE = endpoints.ResourceContainer(
message_types.VoidMessage,
id=messages.IntegerField(1, variant=messages.Variant.INT32))
@endpoints.method(ID_RESOURCE, NewsItem,
path='news/{id}',
http_method='GET',
name='newsitems.getNewsitems')
def news_items_get(self, request):
try:
return STORED_MESSAGES.items[request.id]
except (IndexError, TypeError):
raise endpoints.NotFoundException('News %s not found.' %
(request.id))
APPLICATION = endpoints.api_server([CFCDatastoreApi])