parent
8c014e1292
commit
65414c4e00
@ -0,0 +1,27 @@
|
|||||||
|
from flask import jsonify, Blueprint, url_for
|
||||||
|
from suchwow.models import Post
|
||||||
|
from suchwow import wownero
|
||||||
|
|
||||||
|
|
||||||
|
bp = Blueprint("api", "api")
|
||||||
|
|
||||||
|
@bp.route("/api/list")
|
||||||
|
def api_list():
|
||||||
|
all_posts = []
|
||||||
|
posts = Post.select().where(Post.approved==True)
|
||||||
|
for post in posts:
|
||||||
|
wallet = wownero.Wallet()
|
||||||
|
if wallet.connected:
|
||||||
|
address = wallet.get_address(account=post.account_index)
|
||||||
|
else:
|
||||||
|
address = ''
|
||||||
|
|
||||||
|
payload = {
|
||||||
|
'image': url_for('post.uploaded_file', filename=post.image_name, _external=True),
|
||||||
|
'submitter': post.submitter,
|
||||||
|
'address': address,
|
||||||
|
'title': post.title,
|
||||||
|
'href': url_for('post.read', id=post.id, _external=True)
|
||||||
|
}
|
||||||
|
all_posts.append(payload)
|
||||||
|
return jsonify(all_posts)
|
Reference in new issue