about summary refs log tree commit diff
path: root/gn3/api/rqtl2.py
diff options
context:
space:
mode:
authorAlexander_Kabui2024-11-22 12:33:16 +0300
committerAlexander_Kabui2024-11-22 12:33:16 +0300
commit9773b216d1f92111e2ba9f4f77e78b2ba64ce5f1 (patch)
tree3b573306ec3f5323dc7598261391bd1cf1ab894a /gn3/api/rqtl2.py
parenta47a49a96684108630061f6ada0285fd05c28d4a (diff)
downloadgenenetwork3-9773b216d1f92111e2ba9f4f77e78b2ba64ce5f1.tar.gz
feat: Add new endpoint to read stdout given a file identifier.
Diffstat (limited to 'gn3/api/rqtl2.py')
-rw-r--r--gn3/api/rqtl2.py12
1 files changed, 12 insertions, 0 deletions
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/<indetifier>",  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()})