from flask import Flask, request from qrt import generate from base64 import b64encode from binascii import b2a_base64 from cStringIO import StringIO from traceback import format_exc app = Flask(__name__) @app.route("/", methods=["GET", "POST"]) def index(): try: html = "
empty
" else: html %= request.form["text"] im = generate(request.form["text"]) buf = StringIO() im.save(buf, format="JPEG") html += "" % b2a_base64(buf.getvalue()) else: html %= "" return html except: return "" % format_exc() app.run(host="0.0.0.0", port=5000)