Nathaniel Manista | 4e7ea93 | 2015-10-07 14:34:08 +0000 | [diff] [blame^] | 1 | gRPC in 3 minutes (Python) |
| 2 | ======================== |
| 3 | |
| 4 | Background |
| 5 | ------------- |
| 6 | For this sample, we've already generated the server and client stubs from |
| 7 | [helloworld.proto][] and we'll be using a specific reference platform. |
| 8 | |
| 9 | Prerequisites |
| 10 | ------------- |
| 11 | |
| 12 | - Debian 8.2 "Jessie" platform with `root` access |
| 13 | - `git` |
| 14 | - `python2.7` |
| 15 | - `pip` |
| 16 | - Python development headers |
| 17 | |
| 18 | Set-up |
| 19 | ------- |
| 20 | ```sh |
| 21 | $ # install the gRPC Core: |
| 22 | $ sudo apt-get install libgrpc-dev |
| 23 | $ # install gRPC Python: |
| 24 | $ sudo pip install -U grpcio==0.11.0b1 |
| 25 | $ # Since this "hello, world" example uses protocol buffers: |
| 26 | $ sudo pip install -U protobuf==3.0.0a3 |
| 27 | $ # Clone the repository to get the example code: |
| 28 | $ git clone https://github.com/grpc/grpc |
| 29 | $ # Navigate to the "hello, world" Python example: |
| 30 | $ cd grpc/examples/python/helloworld |
| 31 | ``` |
| 32 | |
| 33 | Try it! |
| 34 | ------- |
| 35 | |
| 36 | - Run the server |
| 37 | |
| 38 | ```sh |
| 39 | $ python2.7 greeter_server.py & |
| 40 | ``` |
| 41 | |
| 42 | - Run the client |
| 43 | |
| 44 | ```sh |
| 45 | $ python2.7 greeter_client.py |
| 46 | ``` |
| 47 | |
| 48 | Tutorial |
| 49 | -------- |
| 50 | |
| 51 | You can find a more detailed tutorial in [gRPC Basics: Python][] |
| 52 | |
| 53 | [helloworld.proto]:../protos/helloworld.proto |
| 54 | [Install gRPC Python]:../../src/python#installation |
| 55 | [gRPC Basics: Python]:http://www.grpc.io/docs/tutorials/basic/python.html |