diff options
Diffstat (limited to 'chall/src/transpile.php')
| -rw-r--r-- | chall/src/transpile.php | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/chall/src/transpile.php b/chall/src/transpile.php new file mode 100644 index 0000000..44de755 --- /dev/null +++ b/chall/src/transpile.php @@ -0,0 +1,18 @@ +<?php + + +$input = json_decode(file_get_contents('php://input'), true); +if (!isset($input["code"])) { + echo json_encode(array("error" => "no input data")); + die(); +} + +$tmpfname = tempnam("/tmp", "lolpython_prog_"); +$handle = fopen($tmpfname, "w"); +fwrite($handle, $input["code"]); +fclose($handle); + +$stdout = shell_exec("python2 /opt/lolcode.py $tmpfname"); + +echo(json_encode(array("result" => $stdout))); +?>
\ No newline at end of file |
