add new api
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from datetime import datetime
|
||||
import grpc
|
||||
from google.protobuf.timestamp_pb2 import Timestamp
|
||||
from datetime import datetime
|
||||
@@ -15,13 +16,17 @@ def get_auto_avg_cost(
|
||||
distance_covered,
|
||||
color
|
||||
):
|
||||
# url = f"{env.str('RPC_IP')}:{env.str('RPC_PORT')}"
|
||||
# channel = grpc.insecure_channel(url)
|
||||
channel = grpc.insecure_channel("192.168.1.120:50051")
|
||||
channel = grpc.insecure_channel("94.230.232.47:50051")
|
||||
stub = auto_pb2_grpc.AutoAvgCostServiceStub(channel)
|
||||
|
||||
|
||||
ts = Timestamp()
|
||||
ts.FromDatetime(manufacture_date)
|
||||
if isinstance(manufacture_date, datetime):
|
||||
dt = manufacture_date
|
||||
else:
|
||||
dt = datetime.combine(manufacture_date, datetime.min.time())
|
||||
|
||||
ts.FromDatetime(dt)
|
||||
|
||||
response = stub.AutoAvgCost(auto_pb2.AutoAvgCostRequest(
|
||||
brand=brand,
|
||||
@@ -32,6 +37,7 @@ def get_auto_avg_cost(
|
||||
distance_covered=distance_covered,
|
||||
color=color,
|
||||
))
|
||||
print("manufacture_date:", manufacture_date, type(manufacture_date))
|
||||
|
||||
return {
|
||||
"avg_cost": response.avg_cost,
|
||||
|
||||
Reference in New Issue
Block a user