tcc/FlaskAPI/controllers/image.py

29 lines
948 B
Python
Raw Normal View History

2023-09-24 13:56:01 +00:00
import io
from services.image import ImageService
from flask import request, Response, Blueprint, jsonify, send_file
image_blueprint = Blueprint('image_blueprint', __name__)
image_service = ImageService()
@image_blueprint.route('/image/load-small-image', methods=['GET'])
def get_simple_image():
2023-09-24 13:56:01 +00:00
return send_file(io.BytesIO(image_service.get_simple_image()),
mimetype='image/png',
as_attachment=True,
download_name='small-image.png')
@image_blueprint.route('/image/load-big-image', methods=['GET'])
def get_big_image():
2023-09-24 13:56:01 +00:00
return send_file(io.BytesIO(image_service.get_big_image()),
mimetype='image/png',
as_attachment=True,
download_name='big-image.png')
@image_blueprint.route('/image/save-big-image', methods=['POST'])
def save_image():
2023-09-21 20:57:47 +00:00
image_service.save_image(request.get_data())
2023-09-24 13:56:01 +00:00
return "OK", 200