From 8c58c493be5e1fe18ca476f8f643c3eb5d32bc09 Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Wed, 19 Apr 2023 10:00:46 +0200 Subject: [PATCH] Added returned type to python backend and frontend --- Backend-libXML/Parser.py | 4 ++-- Backend-libXML/main.py | 2 +- Frontend/assets/scripts/tools/scripts.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Backend-libXML/Parser.py b/Backend-libXML/Parser.py index 7dcb211..a8ea334 100644 --- a/Backend-libXML/Parser.py +++ b/Backend-libXML/Parser.py @@ -54,12 +54,12 @@ def xpath(source: str, xpath: str) -> str: # root.xpath can return 4 types: float, string, bool and list. # List is the only one that can't be simply converted to str if type(result) is not list: - return str(result) + return str(result), type(result).__name__ else: result_string = "" for e in result: result_string += etree.tostring(e, pretty_print=True).decode() + "\n" - return result_string + return result_string, "list" diff --git a/Backend-libXML/main.py b/Backend-libXML/main.py index c0a962b..4445cab 100644 --- a/Backend-libXML/main.py +++ b/Backend-libXML/main.py @@ -35,7 +35,7 @@ def process_xml(request: request, type: str) -> str: elif (type == "xslt"): response_json['result'] = Parser.xslt(data, process) elif (type == "xpath"): - response_json['result'] = Parser.xpath(data, process) + response_json['result'], response_json['type'] = Parser.xpath(data, process) elif (type == "prettify"): response_json['result'] = Parser.formatXML(data, True) elif (type == "minimize"): diff --git a/Frontend/assets/scripts/tools/scripts.js b/Frontend/assets/scripts/tools/scripts.js index db2c22c..e990108 100644 --- a/Frontend/assets/scripts/tools/scripts.js +++ b/Frontend/assets/scripts/tools/scripts.js @@ -244,7 +244,7 @@ function performRequest(endpoint, checkXML, checkTransform) { if (!empty) { restRequest(port, endpoint, xmlData, transformData).then(function (result) { document.getElementById("resultArea").value = result.result; - document.getElementById("procinfo").innerText = ' Computed using '.concat(" ", result.processor); + document.getElementById("procinfo").innerText = ' Computed using '.concat(" ", result.processor, ". Returned: ", result.type); if (result.status = "OK") { document.getElementById("procinfo").innerText = document.getElementById("procinfo").innerText.concat(" in ", result.time, "ms"); procinfo.style.color = "#30aa58";