forked from tanner/qotnews
gotta try this on live.
This commit is contained in:
@@ -67,9 +67,9 @@ def put_story(story):
|
||||
logging.error('Problem putting MeiliSearch story: {}'.format(str(e)))
|
||||
return False
|
||||
|
||||
def search(q):
|
||||
def search(q, skip=0, limit=250):
|
||||
try:
|
||||
params = dict(q=q, limit=250)
|
||||
params = dict(q=q, skip=skip, limit=limit)
|
||||
r = requests.get(MEILI_URL + 'indexes/qotnews/search', params=params, timeout=2)
|
||||
if r.status_code != 200:
|
||||
raise Exception('Bad response code ' + str(r.status_code))
|
||||
|
@@ -51,8 +51,10 @@ def api():
|
||||
@flask_app.route('/api/search', strict_slashes=False)
|
||||
def apisearch():
|
||||
q = request.args.get('q', '')
|
||||
skip = request.args.get('skip', 0)
|
||||
limit = request.args.get('limit', 20)
|
||||
if len(q) >= 3:
|
||||
results = search.search(q)
|
||||
results = search.search(q, skip=skip, limit=limit)
|
||||
else:
|
||||
results = []
|
||||
return dict(results=results)
|
||||
|
Reference in New Issue
Block a user