feat: add support for multiple label formats in get_label function
This commit is contained in:
@@ -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'))
|
||||
|
||||
Reference in New Issue
Block a user