Skip to content

Commit fefe457

Browse files
fix: correct subprocess handling and HTTP status codes in /library endpoint (fixes #359)
1 parent 0467ce5 commit fefe457

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
@@ -507,18 +507,18 @@ def library(dir):
507507
result = subprocess.run(["cmd.exe", "/c", r"..\library.bat", library_path, filename], cwd=dir_path, check=True, capture_output=True, text=True)
508508
proc = result.stdout
509509
else:
510-
proc = subprocess.check_output([r"../library", library_path, filename], cwd=dir_path)
510+
proc = subprocess.check_output([r"../library", library_path, filename], cwd=dir_path, stderr=subprocess.STDOUT)
511511
proc = proc.decode("utf-8")
512512
resp = jsonify({'message': proc})
513-
resp.status_code = 201
513+
resp.status_code = 200
514514
return resp
515515
except subprocess.CalledProcessError as e:
516516
error_output = get_error_output(e)
517517
resp = jsonify({'message': f'Command execution failed: {error_output}'})
518-
resp.status_code = 500
518+
resp.status_code = 400
519519
return resp
520520
except Exception as e:
521-
resp = jsonify({'message': 'There is an Error'})
521+
resp = jsonify({'message': 'Internal server error'})
522522
resp.status_code = 500
523523
return resp
524524

0 commit comments

Comments
 (0)