File tree 5 files changed +29
-6
lines changed
5 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -13,9 +13,16 @@ Install Grpc Tools
13
13
pip3 install grpcio-tools
14
14
```
15
15
16
- Generate grpc code based on proto file
16
+ Generate gRPC code based on proto file
17
17
```
18
- python3 -m grpc_tools.protoc -I protos --python_out=. --grpc_python_out=. protos/greet.proto
18
+ python3 -m grpc_tools.protoc --python_out=protobufs/ --grpc_python_out=protobufs/ -I protos protos/greet.proto
19
+
20
+ Options Explained
21
+ --python_out: Is where you want the autogenerated gRPC protocol buffers code to go
22
+ --grpc_python_out: Is where you want the autogenerated gRPC python protocols code to go
23
+ -I: Points to the folder where the protos are stored
24
+
25
+ The last argument is the exact proto file you want to use within the folder identified in the -I argument
19
26
```
20
27
21
28
Run the Envoy (The Envoy allows a grpc-web app to communicate with the gRPC server)
Original file line number Diff line number Diff line change 1
- import greet_pb2_grpc
2
- import greet_pb2
3
1
import time
4
2
import grpc
3
+ import os
4
+ import sys
5
+
6
+ # Add the protobufs module directory to sys.path
7
+ parent_dir = os .path .dirname (os .path .abspath (__file__ ))
8
+ protobuf_dir = os .path .join (parent_dir , 'protobufs' )
9
+ sys .path .append (protobuf_dir )
10
+
11
+ from protobufs import greet_pb2
12
+ from protobufs import greet_pb2_grpc
5
13
6
14
def get_client_stream_requests ():
7
15
while True :
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 1
1
from concurrent import futures
2
2
import time
3
+ import os
4
+ import sys
3
5
4
6
import grpc
5
- import greet_pb2
6
- import greet_pb2_grpc
7
+
8
+ # Add the protobufs module directory to sys.path
9
+ parent_dir = os .path .dirname (os .path .abspath (__file__ ))
10
+ protobuf_dir = os .path .join (parent_dir , 'protobufs' )
11
+ sys .path .append (protobuf_dir )
12
+
13
+ from protobufs import greet_pb2
14
+ from protobufs import greet_pb2_grpc
7
15
8
16
class GreeterServicer (greet_pb2_grpc .GreeterServicer ):
9
17
def SayHello (self , request , context ):
You can’t perform that action at this time.
0 commit comments