Fix meilisearch auth
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import database
|
||||
import search
|
||||
import sys
|
||||
import settings
|
||||
import logging
|
||||
|
||||
import json
|
||||
import requests
|
||||
@@ -22,16 +20,8 @@ def database_del_story(sid):
|
||||
session.close()
|
||||
|
||||
def search_del_story(sid):
|
||||
try:
|
||||
r = requests.delete(settings.MEILI_URL + 'indexes/qotnews/documents/'+sid, timeout=2)
|
||||
if r.status_code != 202:
|
||||
raise Exception('Bad response code ' + str(r.status_code))
|
||||
return r.json()
|
||||
except KeyboardInterrupt:
|
||||
raise
|
||||
except BaseException as e:
|
||||
logging.error('Problem deleting MeiliSearch story: {}'.format(str(e)))
|
||||
return False
|
||||
return search.meili_api(
|
||||
requests.delete, 'indexes/qotnews/documents/' + sid)
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) == 2:
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ SEARCH_ENABLED = bool(settings.MEILI_URL)
|
||||
def meili_api(method, route, json=None, params=None, parse_json=True):
|
||||
try:
|
||||
headers = {'Authorization': 'Bearer ' + settings.MEILI_API_KEY}
|
||||
r = method(settings.MEILI_URL + route, json=json, params=params, timeout=4)
|
||||
r = method(settings.MEILI_URL + route, json=json, params=params, headers=headers, timeout=4)
|
||||
if r.status_code > 299:
|
||||
raise Exception('Bad response code ' + str(r.status_code))
|
||||
if parse_json:
|
||||
|
||||
@@ -14,6 +14,7 @@ NUM_TILDES = 5
|
||||
# Leave blank if not using search
|
||||
#MEILI_URL = 'http://127.0.0.1:7700/'
|
||||
MEILI_URL = ''
|
||||
MEILI_API_KEY = ''
|
||||
|
||||
# Readerserver URL
|
||||
# Leave blank if not using, but that defeats the whole point
|
||||
|
||||
Reference in New Issue
Block a user