From 6d4a08f337a6257cf11a36223f3b14c8159d997e Mon Sep 17 00:00:00 2001 From: pluja Date: Thu, 23 Dec 2021 16:14:25 +0100 Subject: [PATCH] auto-generate qrcodes --- kycnot.py | 21 +++++++++++++++++++-- requirements.txt | 2 ++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/kycnot.py b/kycnot.py index a768648..f595784 100755 --- a/kycnot.py +++ b/kycnot.py @@ -13,7 +13,7 @@ from random import randrange import json import datetime import os.path -#import qrcode +import qrcode import httpx import os import re @@ -53,13 +53,30 @@ async def services(request): title="KYC? Not me!", subtitle="Find best NON-KYC online services.")) - @app.route("/about", name="about") async def about(request): template = env.get_template('about.html') r = httpx.get( "https://codeberg.org/schylza/schylza/raw/branch/main/SUPPORT.md") donations = json.loads(r.content) + addresses = [ + {'name': 'btc', + 'address': donations['btc']}, + {'name': 'xmr', + 'address': donations['xmr']}, + {'name': 'nano', + 'address': donations['nano']}, + ] + for ad in addresses: + qr = qrcode.QRCode(version=1, box_size=10, border=4) + # add data to the QR code + qr.add_data(ad['address']) + # compile the data into a QR code array + qr.make() + # transfer the array into an actual image + img = qr.make_image(fill_color="white", back_color="#1a1a1a") + # save it to a file + img.save(f"./static/img/qrcodes/{ad['name']}.png") #await generate_donations_qrcodes(donations) return html(template.render(date=date, title="KYC? Not me!", subtitle="About KYCNOT.ME", diff --git a/requirements.txt b/requirements.txt index c3e2c17..8b9e58c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -34,3 +34,5 @@ ujson==4.0.2 uvloop==0.15.2 websockets==8.1 wrapt==1.12.1 +qrcode +pillow