Small Python client/server app that communicates by gRPC protocol and provides currency exchange rates
- Python 3.7 or higher
- Install Requests library (pip install requests)
- Install google protobuf (pip install protobuf)
- Install gRPC Python scaffold (grpcio, grpcio-tools) as it described in gRPC tutorial.
-
Run the server:
python ex_rates_svc.pyService listens port 50051
-
Run the client providing currency code like USD, EUR, UAH, GBP, etc. as a command line parameter, and optionally ip address of host where ex_rates_svc.py is launched (by default: localhost:50051)
python ex_rates_clnt.py --code USD python ex_rates_clnt.py --code EUR --host ex-rates-service-ip:portThe client prints the rates of the specified currency against to others
For (re)generation of gRPC code integrated into application use grpc_tools.
Run it from the project's root directory:
python -m grpc_tools.protoc -I./protos --python_out=gen --pyi_out=gen --grpc_python_out=gen protos/ex-rates.proto
The generated code drops into gen subfolder