adding flask protobuf

This commit is contained in:
2023-11-04 00:41:12 -03:00
parent ac8bff31f2
commit e8ae8935f2
8 changed files with 49 additions and 59 deletions

View File

@@ -5,20 +5,6 @@ from flask import request, Response, Blueprint, jsonify, send_file
image_blueprint = Blueprint('image_blueprint', __name__)
image_service = ImageService()
@image_blueprint.route('/image/blur', methods=['POST'])
def blur_image():
radius = int(request.args.get('radius'))
image = request.get_data()
if radius and image:
return send_file(io.BytesIO(image_service.box_blur_image(image, radius)),
mimetype='image/png',
as_attachment=True,
download_name='blurred_image.png')
return "Bad request", 400
@image_blueprint.route('/image/load-small-image', methods=['GET'])
def get_simple_image():
return send_file(io.BytesIO(image_service.get_simple_image()),

View File

@@ -1,4 +1,5 @@
from flask import request, Blueprint, jsonify
import helloworld_pb2
simulation_blueprint = Blueprint('simulation_blueprint', __name__)
@@ -28,3 +29,12 @@ def return_ok():
@simulation_blueprint.route('/simulation/json', methods=['GET'])
def return_helloworld():
return simulation_controller.return_helloworld(), 200
@simulation_blueprint.route('/simulation/protobuf', methods=['POST'])
def return_protobuf():
bytes_data = request.data
helloworld = helloworld_pb2.MyObj()
helloworld.ParseFromString(bytes_data)
return helloworld.SerializeToString(), 200