def qrpage():
    #Install Python Modules: (Pillow,qrcode)
    #https://github.com/lincolnloop/python-qrcode
    
    ToQRData = auth.user.username + ' Likes MLP:FIM'
    import qrcode
    import StringIO
    qr = qrcode.QRCode(
        version=1,
        error_correction=qrcode.constants.ERROR_CORRECT_L,
        box_size=10,
        border=1,
    )
    qr.add_data(ToQRData)
    qr.make(fit=True)

    # use an in-memory object to save
    output = StringIO.StringIO()
    img = qr.make_image()
    img.save(output)

    # and the use getvalue() method to get the string
    img_tag = '<img src="data:image/png;base64,%s">' % 
output.getvalue().encode('base64').replace('\n', '')
    return locals()


On Tuesday, October 13, 2015 at 2:05:23 PM UTC-7, Fabiano Almeida wrote:
>
> Hi all!
>
> How to dynamically generate qr code in web2py?
>
> grateful,
>
> Fabiano.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to