From 9773b216d1f92111e2ba9f4f77e78b2ba64ce5f1 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Fri, 22 Nov 2024 12:33:16 +0300 Subject: feat: Add new endpoint to read stdout given a file identifier. --- gn3/api/rqtl2.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gn3/api/rqtl2.py') diff --git a/gn3/api/rqtl2.py b/gn3/api/rqtl2.py index e746918..03cf340 100644 --- a/gn3/api/rqtl2.py +++ b/gn3/api/rqtl2.py @@ -36,3 +36,15 @@ def compute(): return jsonify({"msg": "success", "results": "file_here"}) else: return jsonify({"msg": "fail", "error": "Process failed"}) + + +@rqtl2.route("/stream/", methods=["GET"]) +def stream(indetifier): + """ This endpoints streams stdout from a file expects + the indetifier to be the file """ + output_file = os.path.join(current_app.config.get("TMPDIR"), + f"{indetifier}.txt") + # raise error if file does not exist + with open(output_file) as file_handler: + # rethink how we do the read should this be stream / yield ???? + return jsonify({"data": file_handler.readlines()}) -- cgit 1.4.1