A Docker-based grpc python example.
This is an experimental repo, it was heavily adapted from https://grpc.io/docs/languages/python/quickstart/ - the equivalent proto files have already been compiled and were placed here "as is"
To run the helloworld example (which only has simple Unary request):
- Clone the repo.
- Install Docker
- (Optional) Run
make buildordocker build --tag filfreire/grpc-example-helloworld:latest .. - Run
make runordocker run -it --rm -p 50051:50051 --name helloworld filfreire/grpc-example-helloworld:latest.
If all goes well you should see:
Server listening at '0.0.0.0:50051'In this repo you can also find of the original gRPC Route guide example from the gRPC Basics python tutorial.
To run the route_guide example (which has Unary, client server and bidirectional streams examples):
- Clone the repo.
- Install Docker
- Change to
route_guide/folder (e.g.cd route_guide) - (Optional) Run
make build - Run
make runordocker run -it --rm -p 50051:50051 --name routeguide filfreire/grpc-example-routeguide:latest.
Import the Insomnia collection on this repo, https://raw.githubusercontent.com/filfreire/grpc-example-python/main/grpc_insomnia.json
In case you edited any of the .proto files in this repo, you can run make build-proto to build the protobuf definitions. You'll need to install some dependencies beforehand:
- Install protobuf compiler
- Install
grpcio,grpcio-toolsusingpip. (e.g.sudo pip3 install grpcio grpcio-tools
To compile the proto files from the original repo:
- Clone the original repo:
git clone -b v1.41.0 https://github.com/grpc/grpc - Run python protobuf compiler:
python -m grpc_tools.protoc -I../../protos --python_out=. --grpc_python_out=. ../../protos/helloworld.proto