Create the template for the Flask framework
This commit is contained in:
parent
db65646400
commit
c0f9876184
14 changed files with 266 additions and 0 deletions
16
app/utils/barcode.py
Normal file
16
app/utils/barcode.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import os
|
||||
import qrcode
|
||||
from barcode import Code128
|
||||
from barcode.writer import ImageWriter
|
||||
from flask import current_app
|
||||
|
||||
def generate_barcode(repair_id, tracking_number):
|
||||
# Generate barcode image
|
||||
barcode = Code128(tracking_number, writer=ImageWriter())
|
||||
barcode_path = os.path.join(current_app.config['UPLOAD_FOLDER'], f'barcode_{repair_id}.png')
|
||||
barcode.save(barcode_path)
|
||||
# Optionally, also generate QR code
|
||||
qr = qrcode.make(tracking_number)
|
||||
qr_path = os.path.join(current_app.config['UPLOAD_FOLDER'], f'qr_{repair_id}.png')
|
||||
qr.save(qr_path)
|
||||
return barcode_path
|
||||
Loading…
Add table
Add a link
Reference in a new issue