-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
39 lines (29 loc) · 867 Bytes
/
server.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
34
35
36
37
38
39
const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
var cmd=require('node-cmd');
const app = express();
const port = 3005;
var process=cmd.get('node');
console.log(process.pid);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(path.join(__dirname, '/build')));
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname+'/client/build/index.html'));
});
app.get('/hello', (req, res) => {
res.send("Hello From Express");
});
app.post('/send', (req, res) => {
cmd.get(
req.body.post,
function(err, data, stderr){
console.log(data)
}
);
res.send(
`This is what you sent me: ${req.body.post}`,
);
});
app.listen(port, () => console.log(`Example app listening on port ${port}!`));