blob: 44de755615058d8721eb49bee12d614d511ae2ab (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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)));
?>
|