Skip to content

Instantly share code, notes, and snippets.

@sysr-q
Created June 15, 2013 09:53
Show Gist options
  • Save sysr-q/5787586 to your computer and use it in GitHub Desktop.
Save sysr-q/5787586 to your computer and use it in GitHub Desktop.
Generate on-the-fly QR codes, and send them out via Flask.
# -*- coding: utf-8 -*-
from flask import Flask, send_file
import qrcode
from StringIO import StringIO
app = Flask(__name__)
@app.route("/qr/<path:url>")
@app.route("/qr")
def qr_route(url="http://dongcorp.org"):
qr = qrcode.make(url)
img = StringIO()
qr.save(img)
img.seek(0)
return send_file(img, mimetype="image/png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment