From a3e7aaa4da9e815d06b749c83054af21f47a6665 Mon Sep 17 00:00:00 2001 From: AB Date: Sun, 26 May 2019 16:17:43 +0300 Subject: [PATCH] add limit and offset to mods uri --- hexound.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/hexound.py b/hexound.py index 791be45..f0f63e9 100644 --- a/hexound.py +++ b/hexound.py @@ -1,8 +1,7 @@ from flask import Response, render_template, request, Flask, send_file, jsonify import json -import sqlite3 +#import sqlite3 from flask_cors import CORS -from pprint import pprint app = Flask(__name__, static_folder='mods') CORS(app) @@ -16,6 +15,8 @@ def isset(i): @app.route("/mods") def mods(): mods = None + limit = request.args.get('limit', default = 20, type = int) + offset = request.args.get('offset', default = 0, type = int) with open('mods.json') as f: mods = json.load(f) for mod in mods: @@ -23,12 +24,9 @@ def mods(): isinstance(mod['time'], str) except: mod['time'] = '1522011600' - return jsonify(mods) - -@app.route('/login', methods=['GET', 'POST']) -def login(): - if request.method == 'POST': - return '213' + #limit = len(mods) if limit > len(mods) else limit + #offset = len(mods)-limit if offset > len(mods) else offset + return jsonify(mods[offset:offset+limit]) @app.route("/usr", methods = ['POST']) def usr_reg():