summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Dobrowolski <admin@tastycode.pl>2017-01-17 00:02:32 +0100
committerPiotr Dobrowolski <admin@tastycode.pl>2017-01-17 00:02:32 +0100
commitdc1a83c9819c8c4a58481d637ac804fe2d457a93 (patch)
tree6da5c3fb37a3f9199d2144989733829b139296ec
parent69f66c2f62082acc6b9d163a20a06794bc92b3a7 (diff)
downloadbitvend-dc1a83c9819c8c4a58481d637ac804fe2d457a93.tar.gz
bitvend-dc1a83c9819c8c4a58481d637ac804fe2d457a93.tar.bz2
bitvend-dc1a83c9819c8c4a58481d637ac804fe2d457a93.tar.xz
bitvend-dc1a83c9819c8c4a58481d637ac804fe2d457a93.zip
Modify qrcode caching a little bit
-rw-r--r--bitvend.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/bitvend.py b/bitvend.py
index 9174e2e..0eaf962 100644
--- a/bitvend.py
+++ b/bitvend.py
@@ -50,15 +50,16 @@ def reclaim(tx_hash):
flask.abort(404)
-@app.route('/qrcode')
-def qrcode_gen():
+@app.route('/qrcode/<path:data>')
+def qrcode_gen(data):
bio = six.BytesIO()
qr = qrcode.QRCode(border=0, box_size=50)
- qr.add_data(flask.request.args['data'])
+ qr.add_data(data)
img = qr.make_image(image_factory=qrcode.image.svg.SvgPathFillImage)
img.save(bio)
- return bio.getvalue(), {
- 'Content-Type': 'image/svg+xml'
+ return bio.getvalue(), 200, {
+ 'Content-Type': 'image/svg+xml',
+ 'Cache-Control': 'public,max-age=3600',
}
@app.context_processor
@@ -68,8 +69,7 @@ def ctx_utils():
'to_local_currency': to_local_currency,
'format_btc': format_btc,
'sat_to_btc': sat_to_btc,
- 'qrcode': lambda data: flask.url_for('qrcode_gen') + '?' + urllib.parse.urlencode({
- 'data': data})
+ 'qrcode': lambda data: flask.url_for('qrcode_gen', data=data),
}
if __name__ == "__main__":
@@ -77,7 +77,8 @@ if __name__ == "__main__":
db.create_all()
threading.Thread(target=app.run, kwargs={
- 'host': '0.0.0.0'
+ 'host': '0.0.0.0',
+ 'processes': 8,
}, daemon=True).start()
proc.start()
dev.run()