La configuración básica de ProtoRPC hello world no funciona

i setup the ProtoRPC hello app and it doesn't work i'm using this to post to it

$.ajax({url: "http://wordninjabackend.appspot.com/hello",
type: 'POST',
contentType: 'application/json',
data: "{ my_name: Bob }",
dataType: 'json',
success: function(response) {
    // The response is { hello: “Hello there, Bob!” }
        alert(response.hello);
    }
});

and i'm geting: 405 Method Not Allowed

app.yaml

application: wordninjabackend
version: 1
api_version: 1
runtime: python

handlers:
- url: .*
script: main.py

Alright it is python on app engine, its just the sample program so it has to be something wrong with my post to the server

preguntado el 01 de febrero de 12 a las 04:02

You need to post your app.ymal and register code of service -

2 Respuestas

With protorpc, it expects the remote method name in your HelloService to be on the url you post to.

If you're using this code to register the service mapping,

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

then you need to change your post url to this:

http://wordninjabackend.appspot.com/hello.hello

The extra ".hello" refers to the method "hello" in the HelloService class. If you rename that method to fred, you'll also need to change that to .fred

For more on how this works, just read further down the page, where they develop PostService for the guestbook application.

https://developers.google.com/appengine/docs/python/tools/protorpc/overview#The_Hello_World_of_ProtoRPC

Respondido el 08 de Septiembre de 12 a las 16:09

I was also finding the ProtoRPC hello app example hard to understand since it lacked an example for calling the service. I found the simplest way to test the hello word app is to use a curl commend from a unix type terminal such as:

curl -H \
'content-type:application/json' -d \
'{ "my_name": "Bob" }' http://localhost:8083/hello.hello

be sure to use your own localhost:portnumber for the URL

and you will receive the response:

{"hello": "Hello there, Bob!"}

if you are using curl in powershell, just get rid of the \'s and put the entire curl command on one line.

Once you see it working there, you can try an $.ajax call.

Respondido 27 Oct 12, 23:10

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.