0

私はかなり単純な Hello World ProtoRPC App Engine の例を動作させようとしましたが、役に立ちませんでした。残念ながら、ウェブサイトのコードは機能していないようです。考えられる解決策をいくつか調べましたが、完全なワーキング セットを見つけることができませんでした。どんな助けでも大歓迎です!以下のエラー (またはその欠如) を確認できます。

app.yaml

application: proto-test
version: 1
runtime: python27
api_version: 1
threadsafe: false

handlers:
- url: /hello.*
  script: hello.py

こんにちは。

from protorpc import messages
from protorpc import remote
from protorpc.wsgi import service

package = 'hello'

# Create the request string containing the user's name
class HelloRequest(messages.Message):
    my_name = messages.StringField(1, required=True)

# Create the response string
class HelloResponse(messages.Message):
    hello = messages.StringField(1, required=True)

# Create the RPC service to exchange messages
class HelloService(remote.Service):

    @remote.method(HelloRequest, HelloResponse)
    def hello(self, request):
        return HelloResponse(hello='Hello there, %s!' % request.my_name)

# Map the RPC service and path (/hello)
app = service.service_mappings([('/hello', HelloService)])

カールコマンド

curl -H 'content-type:application/json' -d '{"my_name":"test1"}' http://proto-test.appspot.com/hello.hello

コマンドラインで上記のコマンドを実行すると、エラーなしでプロンプトが返されます。私のログは、curl コマンドが機能していたことを示していますが、応答がありませんでした。ログには次のように表示されます。

2013-05-08 22:27:07.409 /hello.hello 200 522ms 0kb curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
2620:0:10c8:1007:a800:1ff:fe00:33af - - [08/May/2013:14:27:07 -0700] "POST /hello.hello HTTP/1.1" 200 0 - "curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3" "proto-test.appspot.com" ms=523 cpu_ms=133 loading_request=1 app_engine_release=1.8.0 instance=00c61b117c66197ad84ad9bc61485b292e5129

I 2013-05-08 22:27:07.409
This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application.

Chrome JS コンソールを介した Ajax 呼び出しは次を返しました: SyntaxError: Unexpected token ILLEGAL :

$.ajax({url: ‘/hello.hello’, type: 'POST', contentType: 'application/json', data: ‘{ "my_name": "Bob" }’,dataType: 'json',success: function(response){alert(response.hello);}});
4

1 に答える 1