diff options
| author | Yuval Adam <yuval@segmanta.com> | 2014-04-28 15:57:27 +0300 |
|---|---|---|
| committer | Yuval Adam <yuval@segmanta.com> | 2014-04-28 15:57:27 +0300 |
| commit | 16c7d11fa9c60cc74d149bf4fa11b0a394ce3916 (patch) | |
| tree | afae910a6b1180416b51fdb3f1617b212a3b52e1 | |
| parent | cb4fdceb8668c006d09158a8d9bd90eaf25189f2 (diff) | |
Add sample code
| -rw-r--r-- | README.md | 18 | ||||
| -rw-r--r-- | server.py | 23 |
2 files changed, 41 insertions, 0 deletions
@@ -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() |
