modificando json e protobuf
This commit is contained in:
1 parent
1eb02db473
commit
95a85be35d
15 files changed
+163
-65
No files matched your search
@@ -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