-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
34 lines (27 loc) · 871 Bytes
/
index.js
File metadata and controls
34 lines (27 loc) · 871 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
const express = require("express");
const app = express();
app.use(express.static('.'));
app.get('/get/test/data', (requset, responce) => {
// responce.send('It is test string data');
// console.log('requset', requset);
// console.log('responce', responce);
fs.readFile('./responses/data.json', 'utf-8', (err, data) => {
console.log('fs', err, data);
// console.log(JSON.parse(data));
responce.send(data);
});
});
const fs = require('fs');
fs.readFile('./responses/data.json', 'utf-8', (err, data) => {
console.log('fs', err, data);
if (!err) {
const obj = JSON.parse(data);
console.log(obj);
obj.third = 'THREE';
fs.writeFile('./responses/data.json', JSON.stringify(obj), (err) => {
})
}
});
app.listen(5000, () => {
console.log('Server start on port 5000!')
});