服务端:
客户端:
import xmlrpclib
from SimpleXMLRPCServer import SimpleXMLRPCServer
def get_info(data):
file_path = data['path']
fp = open(file_path, "rb")
result = xmlrpclib.Binary(fp.read())
fp.close()
return result
server = SimpleXMLRPCServer(("0.0.0.0", 8080))
print "start service get power on 0.0.0.0 8080.."
server.register_function(get_info, "get_info")
server.serve_forever()
客户端:
import xmlrpclib
server_power = xmlrpclib.ServerProxy("http://192.168.25.107:8080/")
data = {
"path": "C:\Users\Administrator\Desktop\main_window.py"
}
file_info = server_power.get_info(data).data
fp = open("file.txt", "wb")
fp.write(file_info)
fp.close()