Python implementation of a gRPC Server and Client (based on this repo) with an Envoy that can interact with gRPC web applications.
brew install envoy
pip3 install grpcio-tools
python3 -m grpc_tools.protoc --python_out=protobufs/ --grpc_python_out=protobufs/ -I protos protos/greet.proto
Options Explained
--python_out: Is where you want the autogenerated gRPC protocol buffers code to go
--grpc_python_out: Is where you want the autogenerated gRPC python protocols code to go
-I: Points to the folder where the protos are stored
The last argument is the exact proto file you want to use within the folder identified in the -I argument
If you have gRPC web app that you need to connect to the gRPC server, you will need an Envoy. Current web broswers cannot communicate over http2 so the envoy acts as an intermediatry between http2 and http1.
envoy -c envoy.yaml
Note: Ensure that the your web app connects to the Envoy's port and not the gRPC server's port (in this example the Envoy is on port 1025).
python3 server.py
python3 client.py
The web app in grpc-web-app is a React app built with Vite.
cd grpc-web-app
npm install
npm start
The dev server runs on http://localhost:3000. npm run build writes a production bundle to grpc-web-app/dist and npm test runs the tests with Vitest.