-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambda.js
More file actions
executable file
·32 lines (25 loc) · 882 Bytes
/
lambda.js
File metadata and controls
executable file
·32 lines (25 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var child_process = require('child_process');
var path = require('path');
exports.handler = function(event, context, callback) {
child_process.execFile('/bin/cp', ['--no-target-directory', path.resolve("./txtof"), '/tmp/txtof']);
child_process.execFile('/bin/chmod', ['777', '/tmp/txtof']);
var json = JSON.parse(event['body']);
var child = child_process.spawn('/tmp/txtof');
var out = "";
child.stdin.write(json["data"]);
child.stdout.on('data', function (data) { out += data; });
child.on('close', function(code) {
if(code !== 0) {
return context.done(out);
}
var responseBody = {
html: out
};
var response = {
statusCode: 200,
body: JSON.stringify(responseBody)
};
context.done(null, response);
});
child.stdin.end();
}