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