From 16c7d11fa9c60cc74d149bf4fa11b0a394ce3916 Mon Sep 17 00:00:00 2001 From: Yuval Adam Date: Mon, 28 Apr 2014 15:57:27 +0300 Subject: Add sample code --- README.md | 18 ++++++++++++++++++ server.py | 23 +++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 server.py diff --git a/README.md b/README.md index 9d43e3f..ea73baa 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ # ZeroRPC Test A simple test to get ZeroRPC for Python running on Heroku. + +## Local Dev + +### Server + +```bash +$ python server.py +``` + +### Client +```bash +$ zerorpc -j tcp://localhost:4242 add_42 1 +43 +$ zerorpc tcp://localhost:4242 add_man 'I own a mint-condition Volkswagen Golf' +"I own a mint-condition Volkswagen Golf, man!" +$ zerorpc tcp://localhost:4242 boat 'I own a mint-condition Volkswagen Golf, man!' +"I'm on a boat!" +``` diff --git a/server.py b/server.py new file mode 100644 index 0000000..caa08de --- /dev/null +++ b/server.py @@ -0,0 +1,23 @@ +import zerorpc + + +class Cooler(object): + def add_man(self, sentence): + """ End a sentence with ", man!" to make it sound cooler, and + return the result. """ + return sentence + ", man!" + + def add_42(self, n): + """ Add 42 to an integer argument to make it cooler, and return the + result. """ + return n + 42 + + def boat(self, sentence): + """ Replace a sentence with "I'm on a boat!", and return that, + because it's cooler. """ + return "I'm on a boat!" + + +s = zerorpc.Server(Cooler()) +s.bind("tcp://0.0.0.0:4242") +s.run() -- cgit v1.3.1