diff options
author | 2022-11-16 01:36:31 -0500 | |
---|---|---|
committer | 2022-11-16 01:36:31 -0500 | |
commit | 28bc96a2b9135fd9e67e28309e64449cae28a106 (patch) | |
tree | fd8608d70d5fee4b3ab2ee5d7732478d5efbd769 | |
parent | Implement attachment support (diff) |
Add attachment to API response
-rw-r--r-- | snekbox/api/resources/eval.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/snekbox/api/resources/eval.py b/snekbox/api/resources/eval.py index 1df6c1b..80c9ec4 100644 --- a/snekbox/api/resources/eval.py +++ b/snekbox/api/resources/eval.py @@ -77,9 +77,13 @@ class EvalResource: args = req.media.get("args", ("-c",)) try: - result = self.nsjail.python3(code, py_args=args) + result, attachments = self.nsjail.python3(code, py_args=args) except Exception: log.exception("An exception occurred while trying to process the request") raise falcon.HTTPInternalServerError - resp.media = {"stdout": result.stdout, "returncode": result.returncode} + resp.media = { + "stdout": result.stdout, + "returncode": result.returncode, + "attachments": [atc.to_dict() for atc in attachments], + } |