2013-03-08 79 views
3

正如標題所示我的API是不是在資源管理器中,我所有的日誌顯示如下:我的API不會在瀏覽器中顯示和記錄只顯示500

INFO  2013-03-08 13:39:08,182 dev_appserver.py:723] Internal redirection to http://127.0.0.1:8080/_ah/spi/BackendService.getApiConfigs 
INFO  2013-03-08 13:39:08,198 dev_appserver.py:3104] "GET /_ah/api/discovery/v1/apis HTTP/1.1" 500 - 

相關處理程序從我的app.yaml文件看起來如下:

13 # Endpoint handlers 
14 - url: /_ah/spi/.* 
15 script: main.app 

而且從main.py我的代碼如下:

from google.appengine.ext import endpoints 
from protorpc import messages 

class Location(messages.Message): 
    reg_id = messages.StringField(1) 
    phone_number = messages.StringField(2) 
    latitude = messages.StringField(3) 
    longitude = messages.StringField(4) 

@endpoints.api(name='locations', version='v1', description='Location API for where are you app') 
class LocationApi(remote.Service): 
    @endpoints.method(Location, Location, name='location.insert', path='location', http_method='POST') 
    def insert(self, request): 
     return request 

app = endpoints.api_server([LocationApi]) 

一尼永知道我在做什麼錯了嗎?

回答

1

現在我可以在其他處理程序之前列出端點處理程序。

這工作:

handlers: 
# Endpoint handler 
- url: /_ah/spi/.* 
    script: endpoints.app 

# Page handlers 
- url: /.* 
    script: home.app 

這不起作用:

handlers: 
# Page handlers 
- url: /.* 
    script: home.app 

# Endpoint handler 
- url: /_ah/spi/.* 
    script: endpoints.app 
+0

我觀察到相同的行爲。似乎相當不自然,處理程序必須以特定順序列出。他們至少應該記錄它。 – user443854 2014-05-25 23:25:00

1

請檢查以下內容:

  1. 正如你應該能夠從日誌看,你得到的導入錯誤。在main.py添加此

    from protorpc import remote 
    
  2. documentation

    注:如果你想測試驗證的調用來使用谷歌API的瀏覽器,你還必須提供其客戶ID您的API,它可以通過Endpoints庫作爲endpoints.API_EXPLORER_CLIENT_ID

  3. 再次檢查您的日誌以確保代碼實際運行。你得到500是因爲Python異常被提出,並且你的代碼可能還有其他問題,儘管它看起來不像你發佈的內容。

+0

我已經添加了遠程的導入到我的實際代碼。但那確實是缺失的。 – user672009 2013-03-11 14:47:55

+0

我已經使用以下命令生成api:「endpointscfg.py get_client_lib java -o。-f rest main.LocationApi」其運行沒有錯誤。我也上傳到http://whereareyoudroid.appspot.com ...仍然沒有 – user672009 2013-03-11 14:50:24

+0

我已編輯我的上述答案,以添加一個檢查點 – 2013-03-11 17:14:25

-1

的問題是,你的Python文件找不到進口:

from protorpc import remote 

因此使用終端,跳過GUI,導航到appengine sdk目錄並將您的項目放在那裏。對於mac它是:

/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/ 
相關問題