-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
39 lines (30 loc) · 910 Bytes
/
server.js
File metadata and controls
39 lines (30 loc) · 910 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
39
var express = require("express");
var bodyParser = require('body-parser');
var fs = require("fs");
var app = express();
var LOGGER = require("./modules/logger.js");
var RecordTable = require("./modules/RecordsTable.js");
var mainLogger = new LOGGER("Server");
var recordLogger = new LOGGER("RECORDS");
var recordTable = new RecordTable(undefined, recordLogger);
app.use(express.static("./html/"));
app.use(bodyParser.json());
app.post("/Results", function(req, res){
recordTable.setRecord(req.body);
res.end("Done");
});
app.get("/Results", function(req, res){
var toSend = recordTable.getRecords(req.query.usr);
res.json(toSend);
});
recordTable.loadRecords(function(){
app.listen(8080, function(){
mainLogger.log("Started", "http://localhost:8080/");
});
});
process.on('SIGINT', function() {
recordTable.saveRecords(function(){
mainLogger.log("GoodBye!");
process.exit();
});
});