diff --git a/F25_Bank_Printer.otf b/F25_Bank_Printer.otf new file mode 100755 index 0000000..194065a Binary files /dev/null and b/F25_Bank_Printer.otf differ diff --git a/qr.py b/qr.py index 34afa09..00874d4 100644 --- a/qr.py +++ b/qr.py @@ -1,10 +1,14 @@ -from flask import Flask, Response, redirect, url_for, request, session, abort, render_template +from flask import Flask, Response, redirect, url_for, request, session, abort, render_template, send_file from flask_login import LoginManager, UserMixin, login_required, login_user, logout_user, current_user +from PIL import Image, ImageFont, ImageDraw +from io import BytesIO +import qrcode import json -import datetime import re app = Flask(__name__) +systemURL = 'http://192.168.0.11:5000/' + with open('links.json', 'r') as infile: links = json.load(infile) @@ -23,6 +27,20 @@ def codeLink(code): return None return links[code]['url'] +def serveImage(img): + img_io = BytesIO() + img.save(img_io, 'PNG') + img_io.seek(0) + return send_file(img_io, mimetype='image/png') + +@app.route('/code/') +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) + return serveImage(img) + @app.route("/edit", methods=['GET', 'POST']) def edit(): code = request.form.get("code") diff --git a/readme.md b/readme.md index 59803c2..5a8a639 100644 --- a/readme.md +++ b/readme.md @@ -12,6 +12,7 @@ Python, and the following packages: * flask * flask-login * qrcode +* pillow ##Work in progress The system is currently under initial development, and is **not** operational. \ No newline at end of file diff --git a/static/invalid.png b/static/invalid.png new file mode 100644 index 0000000..2cff7c6 Binary files /dev/null and b/static/invalid.png differ