diff options
Diffstat (limited to 'htdocs/public/metranslator/api/index.ejs')
-rw-r--r-- | htdocs/public/metranslator/api/index.ejs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/htdocs/public/metranslator/api/index.ejs b/htdocs/public/metranslator/api/index.ejs new file mode 100644 index 0000000..47800bd --- /dev/null +++ b/htdocs/public/metranslator/api/index.ejs @@ -0,0 +1,33 @@ +<% + + res.writeHead(200, {'Content-Type': "application/json"}); + + if (get['t']) { + if (get['t'] === "en") { + target = "en"; + } else { + target = "mt"; + } + } else { + res.end(); + } + + if (get['u']) { + text = get['u']; + + if (text.length > 500) { + res.end(); + } + + text = text.split("\"").join("''"); + } else { + res.end(); + } + + aw = JSON.parse(child_process.execSync(`cd /mnt/metranslator-api && node index.js api ${target} "${text}"`).toString()); + last = child_process.execSync("cd /mnt/metranslator-api && git log -1 --pretty=format:'%an'") + aw["system"]["version"] = aw["system"]["version"] + "-" + fs.readFileSync("/mnt/metranslator-api/.git/refs/heads/trunk").toString().substr(0, 8); + aw["system"]["last_author"] = last; + aw["call"] = "cd /mnt/metranslator-api && node index.js api {$target} \"{$text}\""; + + %><%- JSON.stringify(aw); %>
\ No newline at end of file |