~sircmpwn/meta.sr.ht

ref: 0.56.23 meta.sr.ht/metasrht/qrcode.py -rw-r--r-- 279 bytes
699f8ae5 — Peter Sanchez go.mod: core-go version bump 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
import base64
import io
import qrcode

def gen_qr(data):
    img = qrcode.make(data, border=3, box_size=5)
    arr = io.BytesIO()
    img.save(arr, format='PNG')
    encoded = base64.b64encode(arr.getvalue()).decode('utf-8')
    return 'data:image/png;base64,{}'.format(encoded)