ajustando ASP com Flask

This commit is contained in:
2023-09-24 10:56:01 -03:00
parent 125b456743
commit f0fa227035
10 changed files with 80 additions and 93 deletions

View File

@@ -1,11 +1,10 @@
import io
from services.image import ImageService
from static.image_helper import ImageHelper
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'))
@@ -22,7 +21,7 @@ def blur_image():
@image_blueprint.route('/image/load-small-image', methods=['GET'])
def get_simple_image():
return send_file(image_service.get_simple_image(),
return send_file(io.BytesIO(image_service.get_simple_image()),
mimetype='image/png',
as_attachment=True,
download_name='small-image.png')
@@ -30,7 +29,7 @@ def get_simple_image():
@image_blueprint.route('/image/load-big-image', methods=['GET'])
def get_big_image():
return send_file(image_service.get_big_image(),
return send_file(io.BytesIO(image_service.get_big_image()),
mimetype='image/png',
as_attachment=True,
download_name='big-image.png')
@@ -39,3 +38,5 @@ def get_big_image():
@image_blueprint.route('/image/save-big-image', methods=['POST'])
def save_image():
image_service.save_image(request.get_data())
return "OK", 200