~sircmpwn/meta.sr.ht

ref: 72548bd7545f78670878667674cc7645835a17bd meta.sr.ht/metasrht/qrcode.py -rw-r--r-- 279 bytes
72548bd7Drew DeVault API: Updates per core-go auth changes 11 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)