-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
40 lines (30 loc) · 946 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
console.log("server is up!")
const express = require('express');
const Datastore = require('nedb');
var app = express();
var server = app.listen (3000, listening);
function listening() {
console,console.log('listening . . .');
}
app.use (express.static('website'));
app.use (express.json({limit: '10kb' }));
//var fs = require('fs')
//var logger = fs.createWriteStream('log.txt', {
//flags: 'a' // 'a' means appending (old data will be preserved)
//})
//logger.write (console.log);
//app.get ('/flower', sendFlower);
//function sendFlower (request, response) {
// response.send("i love flowers")
//}
const database = new Datastore('output.db');
database.loadDatabase();
//ndjson-to-csv [database] > ['output.csv']
app.post('/api', (request, response) => {
//console.log("data logging happening!");
//console.log(request.body);
const data = request.body;
database.insert(data);
console.log(database);
response.end();
});