-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
39 lines (27 loc) · 858 Bytes
/
server.js
File metadata and controls
39 lines (27 loc) · 858 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
projectData = {};
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({ extended: false}));
app.use(bodyParser.json());
const cors = require('cors');
const { response } = require('express');
app.use(cors());
app.use(express.static('website'));
const port = 8000;
const server = app.listen(port, ()=>{
console.log(`Running localhost: ${port}`)}
);
app.get('/getData', function(req, res) {
res.send(projectData)
});
app.post('/addData', addData);
function addData(req, res) {
let newData = req.body;
console.log('server side data ', newData);
projectData['date'] = newData.date;
projectData['temp'] = newData.temp;
projectData['runDuration'] = newData.runDuration;
projectData['runFeel'] = newData.runFeel;
res.send(projectData);
};