feat: add support for multiple label formats in get_label function

This commit is contained in:
2025-05-26 22:43:52 +03:00
parent 39087fc223
commit 6ca3a9372a
2 changed files with 12 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
from flask import Blueprint, request, send_file
from flask import Blueprint, request, send_file, jsonify
from routes.utils import jwt_protect_blueprint
import sipro.api.printing
@@ -9,9 +9,13 @@ printing_blueprint = jwt_protect_blueprint(Blueprint('printing', __name__))
def get_label():
args = request.args
order_id = args.get('orderId')
data = sipro.api.printing.get_label(order_id)
label_format = args.get('format', 'pdf')
data = sipro.api.printing.get_label(order_id, label_format=label_format)
data.seek(0)
return send_file(data,
as_attachment=True,
download_name='label.pdf',
mimetype='application/pdf')
if label_format == 'pdf':
return send_file(data,
as_attachment=True,
download_name='label.pdf',
mimetype='application/pdf')
return jsonify(data.read().decode('utf-8'))