Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 1 | # Copyright 2015 gRPC authors. |
Jan Tattermusch | 7dfd4ab | 2015-02-25 15:00:46 -0800 | [diff] [blame] | 2 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
Jan Tattermusch | 7dfd4ab | 2015-02-25 15:00:46 -0800 | [diff] [blame] | 6 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
Jan Tattermusch | 7dfd4ab | 2015-02-25 15:00:46 -0800 | [diff] [blame] | 8 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
Jan Tattermusch | 7dfd4ab | 2015-02-25 15:00:46 -0800 | [diff] [blame] | 14 | """The Python implementation of the GRPC helloworld.Greeter client.""" |
| 15 | |
Leifur Halldor Asgeirsson | 4df3987 | 2016-03-03 10:37:31 -0500 | [diff] [blame] | 16 | from __future__ import print_function |
| 17 | |
Nathaniel Manista | 46585e2 | 2016-07-15 22:33:50 +0000 | [diff] [blame] | 18 | import grpc |
Nathaniel Manista | 061d288 | 2015-09-08 21:34:33 +0000 | [diff] [blame] | 19 | |
Jan Tattermusch | 7dfd4ab | 2015-02-25 15:00:46 -0800 | [diff] [blame] | 20 | import helloworld_pb2 |
Nathaniel Manista | c15ee83 | 2016-12-15 22:58:29 +0000 | [diff] [blame] | 21 | import helloworld_pb2_grpc |
Jan Tattermusch | 7dfd4ab | 2015-02-25 15:00:46 -0800 | [diff] [blame] | 22 | |
Jan Tattermusch | 7dfd4ab | 2015-02-25 15:00:46 -0800 | [diff] [blame] | 23 | |
| 24 | def run(): |
ncteisen | 848a749 | 2017-12-12 10:31:47 -0800 | [diff] [blame] | 25 | channel = grpc.insecure_channel('localhost:50051') |
| 26 | stub = helloworld_pb2_grpc.GreeterStub(channel) |
| 27 | response = stub.SayHello(helloworld_pb2.HelloRequest(name='you')) |
| 28 | print("Greeter client received: " + response.message) |
Jan Tattermusch | 7dfd4ab | 2015-02-25 15:00:46 -0800 | [diff] [blame] | 29 | |
| 30 | |
| 31 | if __name__ == '__main__': |
ncteisen | 848a749 | 2017-12-12 10:31:47 -0800 | [diff] [blame] | 32 | run() |