Moar fixes
This commit is contained in:
23
app/app.py
23
app/app.py
@@ -68,11 +68,24 @@ doSearch();
|
||||
"""
|
||||
|
||||
def meili_search(qstr, limit=30):
|
||||
if not qstr.strip(): return []
|
||||
r = requests.post(f"{MEILI_URL}/indexes/library/search",
|
||||
headers={"Authorization": f"Bearer {MEILI_KEY}","Content-Type":"application/json"},
|
||||
data=json.dumps({"q": qstr, "limit": limit}))
|
||||
return r.json().get("hits", [])
|
||||
if not qstr.strip():
|
||||
return []
|
||||
try:
|
||||
r = requests.post(
|
||||
f"{MEILI_URL}/indexes/library/search",
|
||||
headers={"Authorization": f"Bearer {MEILI_KEY}", "Content-Type": "application/json"},
|
||||
data=json.dumps({"q": qstr, "limit": limit}),
|
||||
timeout=5,
|
||||
)
|
||||
if r.status_code != 200:
|
||||
return []
|
||||
return r.json().get("hits", [])
|
||||
except Exception:
|
||||
return []
|
||||
|
||||
@app.get("/health")
|
||||
def health():
|
||||
return "ok"
|
||||
|
||||
@app.get("/")
|
||||
def index():
|
||||
|
Reference in New Issue
Block a user