Hi,
add 2 functinos in myapp/controller/default.py
@service.run
def concat(a,b):
return a+b
@service.jsonrpc
def concat2(a,b):
return a+b
test them using browser
1)
http://127.0.0.1:8000/myapp/default/call/run/concat?a=hello&b=world
--> return 'helloworld'
2)
http://127.0.0.1:8000/myapp/default/call/jsonrpc/concat2?a=hello&b=world
--> error
Traceback (most recent call last):
File "gluon/restricted.py", line 192, in restricted
File "C:/web2py/applications/myapp/controllers/default.py", line
100, in <module>
File "gluon/globals.py", line 145, in <lambda>
File "C:/web2py/applications/myapp/controllers/default.py", line 80,
in call
File "gluon/tools.py", line 3937, in __call__
File "gluon/tools.py", line 3776, in serve_jsonrpc
File "gluon/contrib/simplejson/__init__.py", line 386, in loads
File "gluon/contrib/simplejson/decoder.py", line 403, in decode
File "gluon/contrib/simplejson/decoder.py", line 421, in raw_decode
JSONDecodeError: No JSON object could be decoded: line 1 column 0
(char 0)
I am able to run todoApp from web2py book, so json module should be
working, but why cannot I test jsonrpc this way in browser?
Thanks,
Wen