import grpc from protobuf import classify_pb2 from protobuf import classify_pb2_grpc def run(): # 连接 rpc 服务器 channel = grpc.insecure_channel('localhost:50051') # 调用 rpc 服务 stub = classify_pb2_grpc.classifyStub(channel)
response = stub.Classify(classify_pb2.ClassifyRequest(keyword='czl'))
print("Classify client received: " + response.message) if __name__ == '__main__': run()