From 75932ec507778b3f3bd53fc3ce9658fa3488bb76 Mon Sep 17 00:00:00 2001 From: Polish Hammer Date: Fri, 2 May 2025 19:54:08 +0200 Subject: [PATCH] Search client --- ...rch_commqnds.py => file_search_commands.py | 0 file_search_functions.py | 31 +++++++++++++++++++ 2 files changed, 31 insertions(+) rename file_search_commqnds.py => file_search_commands.py (100%) create mode 100644 file_search_functions.py diff --git a/file_search_commqnds.py b/file_search_commands.py similarity index 100% rename from file_search_commqnds.py rename to file_search_commands.py diff --git a/file_search_functions.py b/file_search_functions.py new file mode 100644 index 0000000..b064447 --- /dev/null +++ b/file_search_functions.py @@ -0,0 +1,31 @@ +import requests + +# Base URL for Flask service +BASE_URL = 'http://192.168.1.15:5000' + + +def find_matches(entries, keywords): + """ + Call the get_share_list endpoint. + entries: int (1-10) + keywords: list of strings + Returns: list of file paths + """ + payload = {'entries': entries, 'keywords': keywords} + response = requests.post(f"{BASE_URL}/get_share_list", json=payload) + response.raise_for_status() + data = response.json() + return data.get('files', []) + + +def publish(file_paths): + """ + Call the get_share_links endpoint. + file_paths: list of file path strings + Returns: list of published URLs + """ + payload = {'file_paths': file_paths} + response = requests.post(f"{BASE_URL}/get_share_links", json=payload) + response.raise_for_status() + data = response.json() + return data.get('links', [])