mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-18 07:42:09 +00:00
aa
This commit is contained in:
@@ -83,7 +83,7 @@ class Librarian(object):
|
|||||||
return page_url
|
return page_url
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def answer_query(self, uuid, query):
|
def answer_query(self, query, uuid):
|
||||||
#Search sql for UUID
|
#Search sql for UUID
|
||||||
#SQL SELECT * FROM RESULTS WHERE UUID = uuid
|
#SQL SELECT * FROM RESULTS WHERE UUID = uuid
|
||||||
uuid_found = False
|
uuid_found = False
|
||||||
@@ -92,13 +92,14 @@ class Librarian(object):
|
|||||||
#ale tymczasowo plik
|
#ale tymczasowo plik
|
||||||
database = json.load(new_file)
|
database = json.load(new_file)
|
||||||
for item in database:
|
for item in database:
|
||||||
if item["UUID"]:
|
if item["UUID"] == uuid:
|
||||||
print (item["UUID"])
|
print (item["UUID"])
|
||||||
uuid_found = True
|
uuid_found = True
|
||||||
self.last_search = item
|
self.last_search = item
|
||||||
if uuid_found:
|
if uuid_found:
|
||||||
return self.last_search
|
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
|
#example not exists
|
||||||
#sample_non_existing_page_url = "https://sci-hub.se/10.4324/9781003006237"
|
#sample_non_existing_page_url = "https://sci-hub.se/10.4324/9781003006237"
|
||||||
@@ -125,22 +126,12 @@ def waitress_run():
|
|||||||
|
|
||||||
@app.route("/query", methods=["POST"])
|
@app.route("/query", methods=["POST"])
|
||||||
def query_database():
|
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)
|
record = json.loads(request.data)
|
||||||
app.logger.info(record)
|
app.logger.info(record)
|
||||||
app.logger.info(record["query"])
|
app.logger.info(record["query"])
|
||||||
app.logger.info(record["UUID"])
|
app.logger.info(record["UUID"])
|
||||||
cl = Librarian()
|
cl = Librarian()
|
||||||
cl.answer_query(record["query"], record["UUID"])
|
answer_data = cl.answer_query(record["query"], record["UUID"])
|
||||||
answer_data = cl.last_search
|
|
||||||
return_data = (
|
return_data = (
|
||||||
jsonify(isError=False, message="Success", statusCode=200, data=answer_data),
|
jsonify(isError=False, message="Success", statusCode=200, data=answer_data),
|
||||||
200,
|
200,
|
||||||
|
|||||||
Reference in New Issue
Block a user