-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequestHandler.js
More file actions
38 lines (33 loc) · 967 Bytes
/
requestHandler.js
File metadata and controls
38 lines (33 loc) · 967 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
32
33
34
35
36
37
38
var exec = require('child_process').exec;
const writeRes = (response, status, info) => {
response.writeHead(status, { 'Content-Type': 'text/plain'});
response.write(info);
response.end();
}
const start = (res) => {
console.log('request handler start was called');
var child = exec('ls -l ../bbia/node_modules');
res.writeHead(200, { 'Content-Type': 'text/plain'});
child.stdout.on('data', function(data) {
res.write(data);
});
child.stderr.on('data', function(data) {
res.write(data);
});
child.on('close', function(code) {
console.log('closing code: ' + code);
res.end();
});
}
const upload = (res) => {
console.log('request handler upload was called');
writeRes(res, 200, 'upload exection');//return 'UPLOAD';
}
const root = (res) => {
console.log('request handler root was called');
writeRes(res, 200, 'ROOT');
}
exports.start = start;
exports.upload = upload;
exports.root = root;
exports.writeRes = writeRes;