modificando json e protobuf

This commit is contained in:
2023-11-04 17:05:55 -03:00
parent 1eb02db473
commit 95a85be35d
15 changed files with 163 additions and 65 deletions

View File

@@ -1,5 +1,5 @@
from flask import request, Blueprint, jsonify
import helloworld_pb2
import person_pb2
simulation_blueprint = Blueprint('simulation_blueprint', __name__)
@@ -26,15 +26,16 @@ def return_ok():
return str(sum), 200
@simulation_blueprint.route('/simulation/json', methods=['GET'])
@simulation_blueprint.route('/simulation/json', methods=['POST'])
def return_helloworld():
return simulation_controller.return_helloworld(), 200
data = request.json
return data, 200
@simulation_blueprint.route('/simulation/protobuf', methods=['POST'])
def return_protobuf():
bytes_data = request.data
helloworld = helloworld_pb2.MyObj()
helloworld = person_pb2.Person()
helloworld.ParseFromString(bytes_data)
return helloworld.SerializeToString(), 200