ReflectRPCJSON-RPC 库工具
ReflectRPC 是一款JSON-RPC 库工具,用于创建自描述
import reflectrpc
import reflectrpc.simpleserver
def add(a, b):
return int(a) + int(b)
rpc = reflectrpc.RpcProcessor()
add_func = reflectrpc.RpcFunction(add, 'add', 'Adds two numbers', 'int',
'Sum of the two numbers')
add_func.add_param('int', 'a', 'First int to add')
add_func.add_param('int', 'b', 'Second int to add')
rpc.add_function(add_func)
server = reflectrpc.simpleserver.SimpleJsonRpcServer(rpc, 'localhost', 5500)
server.run()
连接到服务器
rpcsh localhost 5500
评论
