mirror of
https://git.wownero.com/lza_menace/suchwow.git
synced 2024-08-15 01:03:19 +00:00
add qr codes to posts
This commit is contained in:
parent
09409b80a7
commit
0f1d449e69
3 changed files with 15 additions and 1 deletions
|
@ -5,3 +5,5 @@ peewee
|
|||
gunicorn
|
||||
six
|
||||
praw
|
||||
qrcode
|
||||
Pillow
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
from os import path, remove
|
||||
from io import BytesIO
|
||||
from base64 import b64encode
|
||||
from qrcode import make as qrcode_make
|
||||
from flask import render_template, Blueprint, request, session, flash
|
||||
from flask import send_from_directory, redirect, url_for, current_app
|
||||
from werkzeug.utils import secure_filename
|
||||
|
@ -31,6 +34,8 @@ def top():
|
|||
|
||||
@bp.route("/post/<id>")
|
||||
def read(id):
|
||||
_address_qr = BytesIO()
|
||||
qr_code = None
|
||||
if Post.filter(id=id):
|
||||
wallet = wownero.Wallet()
|
||||
post = Post.get(id=id)
|
||||
|
@ -41,6 +46,9 @@ def read(id):
|
|||
if wallet.connected:
|
||||
address = wallet.get_address(account=post.account_index)
|
||||
transfers = wallet.transfers(account=post.account_index)
|
||||
qr_uri = f'wownero:{address}?tx_description=suchwow%20post%20{post.id}'
|
||||
address_qr = qrcode_make(qr_uri).save(_address_qr)
|
||||
qr_code = b64encode(_address_qr.getvalue()).decode()
|
||||
else:
|
||||
address = "?"
|
||||
transfers = "?"
|
||||
|
@ -48,7 +56,8 @@ def read(id):
|
|||
"post/read.html",
|
||||
post=post,
|
||||
address=address,
|
||||
transfers=transfers
|
||||
transfers=transfers,
|
||||
qr_code=qr_code
|
||||
)
|
||||
else:
|
||||
flash("No meme there, brah")
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
<!-- Payments -->
|
||||
<h2>Payments</h2>
|
||||
<p style="word-break:break-all;">Vote for this post by sending WOW to the following address:<br><i>{{ address }}</i></p>
|
||||
{% if qr_code %}
|
||||
<img src="data:image/png;base64,{{ qr_code }}" width=180 class="center"><br /><br />
|
||||
{% endif %}
|
||||
<h5>WOW Received</h5>
|
||||
{% if transfers.in %}
|
||||
<ul>
|
||||
|
|
Loading…
Reference in a new issue