mirror of
https://github.com/ivanch/tcc.git
synced 2025-08-25 15:21:49 +00:00
modificando json e protobuf
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user