From 31b898ba40dab2cb6fd878bff515c2565cfa679d Mon Sep 17 00:00:00 2001 From: Migatu Date: Mon, 1 Apr 2024 19:09:37 +0200 Subject: [PATCH] aa --- conjurer_librarian/conjurer_librarian.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/conjurer_librarian/conjurer_librarian.py b/conjurer_librarian/conjurer_librarian.py index dd8cd8d..79dba07 100644 --- a/conjurer_librarian/conjurer_librarian.py +++ b/conjurer_librarian/conjurer_librarian.py @@ -83,7 +83,7 @@ class Librarian(object): return page_url return None - def answer_query(self, uuid, query): + def answer_query(self, query, uuid): #Search sql for UUID #SQL SELECT * FROM RESULTS WHERE UUID = uuid uuid_found = False @@ -92,13 +92,14 @@ class Librarian(object): #ale tymczasowo plik database = json.load(new_file) for item in database: - if item["UUID"]: + if item["UUID"] == uuid: print (item["UUID"]) uuid_found = True self.last_search = item if uuid_found: return self.last_search - #self.search_crossref(query=query, uuid=uuid) + self.search_crossref(query=query, uuid=uuid) + return self.last_search #example not exists #sample_non_existing_page_url = "https://sci-hub.se/10.4324/9781003006237" @@ -125,22 +126,12 @@ def waitress_run(): @app.route("/query", methods=["POST"]) def query_database(): - """ - The function `update_music_list` receives a POST request with a JSON payload, logs the received - item, adds it to a music file list, and returns a success message along with the updated record. - :return: The function `update_music_list` is returning a tuple containing a JSON response and a - status code. The JSON response includes keys `isError`, `message`, `statusCode`, and `data`, - with values indicating the success of the operation and the data that was - received and added to the `music_file_list`. - The status code returned is 200, indicating a successful response. - """ record = json.loads(request.data) app.logger.info(record) app.logger.info(record["query"]) app.logger.info(record["UUID"]) cl = Librarian() - cl.answer_query(record["query"], record["UUID"]) - answer_data = cl.last_search + answer_data = cl.answer_query(record["query"], record["UUID"]) return_data = ( jsonify(isError=False, message="Success", statusCode=200, data=answer_data), 200,