-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
47 lines (34 loc) · 1.06 KB
/
Copy pathserver.js
File metadata and controls
47 lines (34 loc) · 1.06 KB
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
43
44
45
46
47
const express = require('express');
const bodyParser = require('body-parser');
const fs = require('fs');
const apiroutes = require('./routes/apiroutes');
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: false
}));
// fs.readFile('./data.json', 'utf8', (err, jsonString) => {
// if (err) {
// console.log("File read failed:", err)
// return
// }
// console.log('File data:', jsonString)
// })
app.use('/api', apiroutes);
// app.post('/calculate', (req, res) => {
// console.log(req.body.height);
// const velocity = Math.sqrt(req.body.height * 2 * 9.8);
// console.log(velocity);
// console.log(req.body.restitution);
// const jsonString = JSON.stringify(customer);
// fs.writeFile('./data.json', jsonString, err => {
// if (err) {
// console.log('Error writing file', err)
// } else {
// console.log('Successfully wrote file');
// console.log(jsonString);
// res.sendFile('/home/mutant/edu/data.json');
// }
// });
// });
app.listen(3000);