我是GAE和API开发的新手。当我尝试部署代码时,我收到了来自GAE的错误消息。
10:01 AM检查端点配置是否已更新。
10:01 AM将在60秒内再次检查。
10:02 AM检查端点配置是否已更新。
10:02 AM无法更新端点配置。已配置/ _ah / spi处理程序,但未在应用程序中找到Google Cloud Endpoints服务。
10:02 AM有关详细信息,请参阅部署疑难解答文档:https://developers.google.com/appengine/docs/python/endpoints/test_deploy#troubleshooting_a_deployment_failure
10:02 AM忽略端点失败并继续更新。
基于错误消息,问题似乎是应用程序没有调用endpoints.api_server(),这不是你在下面的代码中看到的情况。 endpoints.api_server()在最后一行被调用。
import endpoints
from protorpc import remote, messages
from google.appengine.api import memcache, mail
from google.appengine.ext import ndb
from google.appengine.api import taskqueue
from models import Player, Game, Score, NewGameForm, StringMessage, GameForm, PlayerForm, PlayerForms
from utils import get_by_urlsafe, check_winner
from settings import WEB_CLIENT_ID
EMAIL_SCOPE = endpoints.EMAIL_SCOPE
API_EXPLORER_CLIENT_ID = endpoints.API_EXPLORER_CLIENT_ID
@endpoints.api(name='tic_tac_toe',
version='v1',
allowed_client_ids=[WEB_CLIENT_ID, API_EXPLORER_CLIENT_ID],
scopes=[EMAIL_SCOPE])
class TicTacToeApi(remote.Service):
"""Game API"""
@endpoints.method(request_message=PLAYER_REQUEST,
response_message=StringMessage,
path='player',
name='create_player',
http_method='POST')
def create_player(self, request):
"""Check if user name is unique"""
if Player.get_player_by_name(request.name):
raise endpoints.ConflictException('The name has been taken!')
if not mail.is_email_valid(request.email):
raise endpoints.BadRequestException('Please input a valid email address')
player = Player(name=request.name, email=request.email)
player.put()
return StringMessage(message='Player {} created!'.format(request.name))
@endpoints.method(response_message=PlayerForms,
path='player/ranking',
name='get_player_rankings',
http_method='GET')
def get_player_rankings(self, request):
"""Return rankings for all Players"""
players = Player.query(Player.gamesCompleted > 0).fetch()
players = sorted(players, key=lambda x :x._points, reverse=True)
return PlayerForms(items=[player._copyPlayerToForm for player in players])
api = endpoints.api_server([TicTacToeApi])
app.yaml文件有问题吗?
application: tic-tac-toe-api
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: .*
script: main.app
- url: /_ah/spi/.*
script: api.api
libraries:
- name: webapp2
version: "2.5.2"
- name: endpoints
version: 1.0
- name: pycrypto
version: 2.6
请随时告诉我您的想法!非常感谢