Skip to content

Commit 881de2c

Browse files
authored
Merge pull request #405 from GaneshPatil7517/fix/library-endpoint-subprocess-logic
fix: correct subprocess handling and HTTP response logic in /library endpoint (fixes #359)
2 parents 2035143 + fefe457 commit 881de2c

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

fri/server/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,18 +512,18 @@ def library(dir):
512512
result = subprocess.run(["cmd.exe", "/c", r"..\library.bat", library_path, filename], cwd=dir_path, check=True, capture_output=True, text=True)
513513
proc = result.stdout
514514
else:
515-
proc = subprocess.check_output([r"../library", library_path, filename], cwd=dir_path)
515+
proc = subprocess.check_output([r"../library", library_path, filename], cwd=dir_path, stderr=subprocess.STDOUT)
516516
proc = proc.decode("utf-8")
517517
resp = jsonify({'message': proc})
518-
resp.status_code = 201
518+
resp.status_code = 200
519519
return resp
520520
except subprocess.CalledProcessError as e:
521521
error_output = get_error_output(e)
522522
resp = jsonify({'message': f'Command execution failed: {error_output}'})
523-
resp.status_code = 500
523+
resp.status_code = 400
524524
return resp
525525
except Exception as e:
526-
resp = jsonify({'message': 'There is an Error'})
526+
resp = jsonify({'message': 'Internal server error'})
527527
resp.status_code = 500
528528
return resp
529529

0 commit comments

Comments
 (0)