mirror of
				https://github.com/ivanch/tcc.git
				synced 2025-10-31 01:17:37 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			29 lines
		
	
	
		
			948 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			948 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| 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():
 | |
|     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():
 | |
|     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():
 | |
|     image_service.save_image(request.get_data())
 | |
| 
 | |
|     return "OK", 200
 |