diff --git a/requirements.txt b/requirements.txt
index d962a1f..24eabd3 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -5,6 +5,7 @@ gunicorn
requests
cloudflare == 3.0.1
qrcode
+Pillow
ansi2html
cachetools
solana == 0.34.2
diff --git a/server.py b/server.py
index 806e4a2..ff068a4 100644
--- a/server.py
+++ b/server.py
@@ -30,6 +30,7 @@ from solders.hash import Hash
from solders.message import MessageV0
from solders.transaction import VersionedTransaction
from solders.null_signer import NullSigner
+from PIL import Image
app = Flask(__name__)
CORS(app)
@@ -779,7 +780,7 @@ def donate():
cryptoHTML += f'{domain}
'
if address:
cryptoHTML += (
- '
'
)
@@ -796,15 +797,15 @@ def donate():
)
-@app.route("/qrcode/")
-def addressQR(data):
+@app.route("/address/")
+def addressQR(address:str):
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=10,
border=4,
)
- qr.add_data(data)
+ qr.add_data(address)
qr.make(fit=True)
qr_image = qr.make_image(fill_color="#110033", back_color="white")
@@ -816,6 +817,30 @@ def addressQR(data):
return send_file(qr_image_path, mimetype="image/png")
+@app.route("/qrcode/")
+@app.route("/qr/")
+def qr(data:str):
+ qr = qrcode.QRCode(error_correction=qrcode.constants.ERROR_CORRECT_H,box_size=10,border=2)
+ qr.add_data(data)
+ qr.make()
+
+ qr_image:Image.Image = qr.make_image(fill_color="black", back_color="white").convert('RGB')
+
+ # Add logo
+ logo = Image.open("templates/assets/img/favicon/logo.png")
+ basewidth = qr_image.size[0]//3
+ wpercent = (basewidth / float(logo.size[0]))
+ hsize = int((float(logo.size[1]) * float(wpercent)))
+ logo = logo.resize((basewidth, hsize),Image.Resampling.LANCZOS)
+ pos = ((qr_image.size[0] - logo.size[0]) // 2,
+ (qr_image.size[1] - logo.size[1]) // 2)
+ qr_image.paste(logo, pos, mask=logo)
+
+
+ qr_image.save("/tmp/qr_code.png")
+ return send_file("/tmp/qr_code.png", mimetype="image/png")
+
+
# endregion