diff options
| author | Alexander_Kabui | 2024-11-22 12:33:16 +0300 |
|---|---|---|
| committer | Alexander_Kabui | 2024-11-22 12:33:16 +0300 |
| commit | 9773b216d1f92111e2ba9f4f77e78b2ba64ce5f1 (patch) | |
| tree | 3b573306ec3f5323dc7598261391bd1cf1ab894a | |
| parent | a47a49a96684108630061f6ada0285fd05c28d4a (diff) | |
| download | genenetwork3-9773b216d1f92111e2ba9f4f77e78b2ba64ce5f1.tar.gz | |
feat: Add new endpoint to read stdout given a file identifier.
| -rw-r--r-- | gn3/api/rqtl2.py | 12 |
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()}) |
