@@ -32,7 +32,7 @@ def handlecwl(workflow):
32
32
with tempfile .NamedTemporaryFile () as f :
33
33
f .write (request .stream .read ())
34
34
f .flush ()
35
- outdir = tempfile .mkdtemp ()
35
+ outdir = tempfile .mkdtemp (dir = os . path . abspath ( "output" ) )
36
36
proc = subprocess .Popen (["cwl-runner" , os .path .abspath (wf ), f .name ],
37
37
stdout = subprocess .PIPE ,
38
38
stderr = subprocess .PIPE ,
@@ -59,7 +59,30 @@ def index():
59
59
print e
60
60
return str (e ), 500 , {"Content-Type" : "text/plain" }
61
61
62
+ @app .route ("/output" )
63
+ def outindex ():
64
+ try :
65
+ return json .dumps (["%s/%s" % (r [7 :], f2 ) for r , _ , f in os .walk ("output" ) for f2 in f ]), 200 , {"Content-Type" : "application/json" }
66
+ except Exception as e :
67
+ print e
68
+ return str (e ), 500 , {"Content-Type" : "text/plain" }
69
+
70
+ @app .route ("/output/<path:fn>" )
71
+ def outfile (fn ):
72
+ if ".." in fn :
73
+ return "Path cannot contain .." , 400 , {"Content-Type" : "text/plain" }
74
+
75
+ fn = os .path .join ("output" , fn )
76
+
77
+ if not os .path .exists (fn ):
78
+ return "Not found" , 404 , {"Content-Type" : "text/plain" }
79
+
80
+ with open (fn , "r" ) as f :
81
+ return f .read (), 200
82
+
62
83
if __name__ == "__main__" :
63
84
if not os .path .exists ("files" ):
64
85
os .mkdir ("files" )
86
+ if not os .path .exists ("output" ):
87
+ os .mkdir ("output" )
65
88
app .run ()
0 commit comments