-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (29 loc) · 900 Bytes
/
index.js
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
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
let exec = require('child_process').exec;
app.get('/get-info', function (req, res) {
function puts(error, stdout, stderr) { sys.puts(stdout); }
exec('multichain-cli blockchain-building getinfo', function(err, stdout, stderr) {
if (!err) {
console.log(stdout);
res.send(stdout);
} else {
console.log(err);
res.send(err);
}
});
});
app.get('/list-blocks', function (req, res) {
function puts(error, stdout, stderr) { sys.puts(stdout); }
exec('multichain-cli blockchain-building listblocks -100', function(err, stdout, stderr) {
if (!err) {
console.log(stdout);
res.send(stdout);
} else {
console.log(err);
res.send(err);
}
});
});
const server = app.listen(3000, () => console.log('Server is up and running'));