This README provides a step-by-step guide to implementing a simple gRPC-based calculator in Python. The calculator will support basic arithmetic operations: addition, subtraction, multiplication, division, and square root.
- Python 3.6+
- virtualenv (optional but recommended for creating isolated Python environments)
- Install virtualenv (if not already installed):
pip install virtualenv
- Create a virtual environment:
virtualenv myenv
- Activate the virtual environment:
- For Windows:
myenv\Scripts\activate
- For Linux/Mac:
source myenv/bin/activate
- For Windows:
- Install necessary packages:
pip install grpcio grpcio-tools
-
Run the following command to generate the gRPC code:
python -m grpc_tools.protoc -I. --python_out=--grpc_python_out=. calculator.proto
This will generate two files:
- calculator_pb2.py
- calculator_pb2_grpc.py.
-
Running the Server and Client
- Run the Server:
python server.py
- Run the Client:
python client.py
- Run the Server:
Enjoy the application!