diff --git a/qr-labels.py b/qr-labels.py index 7ddcaf7..140c149 100644 --- a/qr-labels.py +++ b/qr-labels.py @@ -6,7 +6,8 @@ from io import BytesIO import json, random, re, string app = Flask(__name__) -systemURL = 'http://192.168.0.11:5000/' +systemURL = 'http://192.168.0.11:5000/' #FULL URL with a '/' at the end +systemURL = 'http://10.0.1.115:5000/' randomchars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789' #note the lack of zero with open('links.json', 'r') as infile: @@ -23,7 +24,7 @@ def randomToken(): return code def codeValidation(code): - if len(code) not in range (5,6): + if len(code) not in range (3,10): return False if re.match('^[\w-]+$', code) is None: return False @@ -55,7 +56,15 @@ def serveCode(code): code = code[:code.find('.')] if codeValidation(code) is False: return send_file('static/invalid.png', mimetype='image/png') - img = qrcode.make(systemURL + code) + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_M, + box_size=8, + border=3, + ) + qr.add_data('systemURL + code') + qr.make(fit=True) + img = qr.make_image(fill_color="black", back_color="white") return serveImage(img) @app.route("/edit", methods=['GET', 'POST']) @@ -87,7 +96,14 @@ def generate(): howmany = request.form.get("howmany") if howmany is None: return render_template('generate.html') - return render_template("message.html", message="Totally generated {} many codes right now.".format(howmany)) + codes = [] + for i in range(0, int(howmany)): + codes.append(createNewCode()) + columns = 4 + codesarray = [codes[i:i+columns] for i in range(0, len(codes), columns)] + saveFile() + humanSystemURL = systemURL[systemURL.find('//')+2:] + return render_template("printlabels.html", codes=codesarray, systemURL=humanSystemURL, codegenURL=systemURL+'code/', format='.png') @app.route("/list") def list(): diff --git a/static/printstyle.css b/static/printstyle.css new file mode 100644 index 0000000..67fb12d --- /dev/null +++ b/static/printstyle.css @@ -0,0 +1,16 @@ +body { + font-size: small; + color: #3B3B3B; + font-family: "Lucida Console", Monaco, monospace; + font-weight: 600; +} + +td { + text-align: center; + padding: 10px; +} + +p { + margin: 1px; + padding: 0px; +} \ No newline at end of file diff --git a/templates/generate.html b/templates/generate.html index 46efea5..40bb9cd 100644 --- a/templates/generate.html +++ b/templates/generate.html @@ -3,7 +3,7 @@ {% block content %}
How many?:
-
+

Note: It is best to print the generated codes immediatly from the result of this generation.
diff --git a/templates/printlabels.html b/templates/printlabels.html new file mode 100644 index 0000000..28cc618 --- /dev/null +++ b/templates/printlabels.html @@ -0,0 +1,28 @@ + + + + Printing QR labels + + + + + + + +{% for row in codes %} + + {% for code in row %} + + {% endfor %} + +{% endfor %} + +
+ +

ELAB KNOWLEDGE SYSTEM

+

{{systemURL}}{{code}}

+
+ + + + \ No newline at end of file