Skip to content

Latest commit

 

History

17 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GrpcServerClientExample

Python implementation of a gRPC Server and Client (based on this repo) with an Envoy that can interact with gRPC web applications.

Getting Started

Install the Envoy in MacOS

brew install envoy

Install Grpc Tools

pip3 install grpcio-tools

Generate gRPC code based on proto file

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  

Set Up the Envoy (if necessary)

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).

Run the gRPC Server

python3 server.py

Run the gRPC Client

python3 client.py

Running the Web App

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.

About

Python implementation of a Graph Server and Client

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages