mirror of
https://github.com/house-of-vanity/hexound.ru.git
synced 2025-07-06 22:34:08 +00:00
add limit and offset to mods uri
This commit is contained in:
14
hexound.py
14
hexound.py
@ -1,8 +1,7 @@
|
|||||||
from flask import Response, render_template, request, Flask, send_file, jsonify
|
from flask import Response, render_template, request, Flask, send_file, jsonify
|
||||||
import json
|
import json
|
||||||
import sqlite3
|
#import sqlite3
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
from pprint import pprint
|
|
||||||
|
|
||||||
app = Flask(__name__, static_folder='mods')
|
app = Flask(__name__, static_folder='mods')
|
||||||
CORS(app)
|
CORS(app)
|
||||||
@ -16,6 +15,8 @@ def isset(i):
|
|||||||
@app.route("/mods")
|
@app.route("/mods")
|
||||||
def mods():
|
def mods():
|
||||||
mods = None
|
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:
|
with open('mods.json') as f:
|
||||||
mods = json.load(f)
|
mods = json.load(f)
|
||||||
for mod in mods:
|
for mod in mods:
|
||||||
@ -23,12 +24,9 @@ def mods():
|
|||||||
isinstance(mod['time'], str)
|
isinstance(mod['time'], str)
|
||||||
except:
|
except:
|
||||||
mod['time'] = '1522011600'
|
mod['time'] = '1522011600'
|
||||||
return jsonify(mods)
|
#limit = len(mods) if limit > len(mods) else limit
|
||||||
|
#offset = len(mods)-limit if offset > len(mods) else offset
|
||||||
@app.route('/login', methods=['GET', 'POST'])
|
return jsonify(mods[offset:offset+limit])
|
||||||
def login():
|
|
||||||
if request.method == 'POST':
|
|
||||||
return '213'
|
|
||||||
|
|
||||||
@app.route("/usr", methods = ['POST'])
|
@app.route("/usr", methods = ['POST'])
|
||||||
def usr_reg():
|
def usr_reg():
|
||||||
|
Reference in New Issue
Block a user