Flask-QR¶
This is simple extension for generating and displaying QR codes with flask.
Installation¶
Install the extension with one of the following commands:
$ pip install Flask-QR
or alternatively if you have pip installed:
$ easy_install Flask-QR
Quickstart¶
Initialize with flask application and default parameters:
from flask_qr import QR
qr = QR(app, mode="google")
Then in your template:
{{ 'I am a Qr-Code' | qrFor }}
Api¶
-
class
flask_qr.
QR
(app=None, mode="google", location="/qr/", errorCorrect="M", margin=4)¶ Object for creating qr codes and links to them.
-
qrFor(url, dimension=200):
Generates a qr code and returns the url.
Parameters: - message – data to encode in the qr code.
- dimension – size of the qr code.
-
qrForJinja(message, dimension=200):
Embedds the qr code in an html image tag.
Parameters: - message – data to encode in the qr code.
- dimension – size of the qr code.
-
Options¶
Option Name | Description |
---|---|
mode |
Select which mode to use, either ‘local’ or ‘google’ |
margin |
Set the margin width. Not that the width is given in number of qr code rows. |
errorCorrect |
Set the error correction level of the qr code.
|
location |
When using local mode, specify where in the static folder qr codes should be stored |