This is a example showing how you can create a service using gRPC.
This code was written as a example only and does not follow any good practice rules, since it wasn't on the scope of this presentation.
- Python 3.9.X (This should work as-is in python 3.10.X)
- Node v17.3.0
To start the gRPC server just execute the following command:
$ python -m venv venv
$ pip install -r requirements.txt
$ python -m server.main
This will start an insecure gRPC server on https://0.0.0.0:50051
ps.: This server uses an insecure channel for communications, although this is not a problem for learning purposes this SHOULD NOT be used as-is in production.
ps².: The creation of a secure channel communication is beyond the scope of this example.
To start the node.js client execute the following commands:
$ cd client_node
$ yarn
(or$ npm install
)$ yarn start
(or$ npm start
)
This will start a client Express app on http://localhost:3000
A file containing some requests examples can be found here.
To start the python client execute the following command:
$ uvicorn client_python.main:app --reload
This will start a client FastAPI app on http://localhost:8000
A file containing some requests examples can be found here.