Introduce limit/offset args for api call

dsc 3 years ago
parent 9d5ef70271
commit 4c858897e3

@ -1,4 +1,5 @@
from flask import jsonify, Blueprint, url_for
from flask import jsonify, Blueprint, url_for, request
from sqlalchemy import desc
from suchwow.models import Post
from suchwow import wownero
@ -7,8 +8,13 @@ bp = Blueprint("api", "api")
@bp.route("/api/list")
def api_list():
limit = request.args.get('limit', 30)
offset = request.args.get('offset', 0)
if limit > 30:
limit = 30
all_posts = []
posts = Post.select().where(Post.approved==True)
posts = Post.select().where(Post.approved==True).order_by(desc(Post.timestamp)).limit(limit).offset(offset)
for post in posts:
wallet = wownero.Wallet()
if wallet.connected: