-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
44 lines (36 loc) · 940 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
40
41
42
//Get metrics from the client continuously
//Store as var metric
var http = require('http');
var fs = require('fs');
var url = require('url');
var path = require('path');
var express = require('express');
var mimeTypes = {
"html": "text/html",
"jpeg": "image/jpeg",
"jpg": "image/jpeg",
"png": "image/png",
"js": "text/javascript",
"css": "text/css"};
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var bodyParser = require('body-parser');
app.use( bodyParser.json() );
app.post('/post', function (req, res) {
console.log(req.body)
if(req.body['decision']){
io.emit('backtowork');
}
else if(req.body['decision']==false){
io.emit('keepworking');
}
else{
console.log("error");
}
res.send('Got a POST request')
})
app.use(express.static(__dirname))
http.listen(3001, function(){
console.log('listening on *:3001');
});