| 1 | Simply see [XML-RPC]. Use the [http://www.freenet.org.nz/dojo/pyjson/ SimpleJSONRPCServer] instead of SimpleXMLRPCServer and you are done! |
| 2 | |
| 3 | You'll also want [http://developer.spikesource.com/wiki/index.php/Article:Accessing_JSON-RPC_with_Python JSON RPC Client] too. |
| 4 | |
| 5 | |
| 6 | {{{ |
| 7 | $ cat testjsonrpc.py |
| 8 | import sys |
| 9 | import jsonrpclib |
| 10 | rpc_srv = jsonrpclib.ServerProxy("http://localhost:8000/json_rpc_srv/") |
| 11 | result = rpc_srv.multiply( int(sys.argv[1]), int(sys.argv[2])) |
| 12 | print "%d * %d = %d" % (int(sys.argv[1]), int(sys.argv[2]), result['result']) |
| 13 | }}} |
| 14 | |
| 15 | There you go! |
| 16 | |
| 17 | Another power of python here! |