I managed to write a flask application which triggers the GRCP client 
automatically because I am importing the result of the client's call to the 
GRCP server in the flask application python file. However, I have noticed 
that the data received by the GRCP client from the GRCP server loses its 
JSON formatting. This is what is happening on the server side to send back 
data to the GRCP client:

json_string = json_format.MessageToJson()  // This works fine and the 
result is as expected when I print it on the server side
return metricDetails_pb2.metricResponse(jsonString=json_string) // This 
return value messes things up and destroys the json formatting from above.
           
metricResponse is defined as a string in the .proto file as below:

message metricResponse {
string jsonString=1;
}

Similarly, the timeSeriesData is a repeated field in the timeSeries message 
of type metric which has two variables inside it:

message metric{
string time=1;
string usage=2;
}

message timeSeries {
repeated metric data=1;
}

As a result, when the flask application simply prints the answer received 
from the client the JSON formatting is lost. What can I do to fix this?
The below is the faulty output:
[image: output.PNG]
On Saturday, May 22, 2021 at 7:34:59 PM UTC+5 Raja Omer wrote:

> Hi guys, Thanks for your suggestions. So, seemingly, I have been able to 
> implement a GRCP server which reads from a csv file and encodes it into 
> JSON. I also have a GRCP client which can make the request and gets back 
> the JSON representation.
>
> In my second part, I want to create a http server which makes a request to 
> the GRCP client for the JSON which gets that via a request to the GRCP 
> server. The final result of the http request is to be displayed on a single 
> page html. What approach or web framework should I use for GRCP? Will flask 
> be the right one or Django or should I read up on something else?
>
> Many thanks!
>
> On Saturday, May 15, 2021 at 6:35:51 AM UTC+5 [email protected] wrote:
>
>>
>>
>> On 15 May 2021, at 6:35 am, Raja Omer <[email protected]> wrote:
>>
>>  Do I have to read the excel in this step using python or do I have to 
>> make a database connection and pull the excel data from a database?
>>
>>
>> You can do this in both ways - one of them (say one protobuf message per 
>> row - for example) is scalable, but admittedly slightly complicated. The 
>> other is simple, but wouldn’t scale well. 
>>
>> For the first approach, you would define a message as follows (for eg):
>>
>> message Row {
>>   Col1 string
>>   Col2 int
>> }
>>
>> Combine it with client side streaming.
>>
>> For the second approach, you would define instead:
>>
>> message excelData {
>>   data bytes
>> }
>>
>> In the first approach, you do more work on both the client side (reading 
>> the excel file, construing a protobuf message) and the same work in reverse 
>> on the server side.
>>
>> In the second approach, you do all the work on the server side.
>>
>> However, the recommended approach is the first one.
>>
>> Hope that helps.
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/71e38d7c-b80a-4119-884e-98019d11df0cn%40googlegroups.com.

Reply via email to