Created
August 31, 2012 06:11
-
-
Save mouseroot/3549560 to your computer and use it in GitHub Desktop.
XMLRPC Client/Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import xmlrpclib,os | |
def main(): | |
cli = xmlrpclib.Server("http://192.168.0.2:1337") | |
for file in os.listdir("send-files"): | |
print file | |
if os.path.isdir("send-files/" + file) == True: | |
print "Dir:",file | |
else: | |
data = open("send-files/" + file,"rb").read() | |
cli.send_file(file,xmlrpclib.Binary(data)) | |
if __name__ == "__main__": | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import SimpleXMLRPCServer | |
def send_file(name,data): | |
print "Recv filename: ",name | |
fh = open("recv-files/"+name,"w") | |
fh.write(data.data) | |
fh.close() | |
return True | |
def main(): | |
print "Application server" | |
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("0.0.0.0",1337)) | |
server.register_function(send_file) | |
server.serve_forever() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment