🐺🎾 Checkpoint

./server.js:1954897/62
This commit is contained in:
Glitch (glitch-hello-node) committed 2021-11-14 05:26:29 +00:00
1 parent b2ced5bc42
commit 4631ab98e8
2 files changed
+13 -2

No files matched your search

+2 -2
View File
@@ -11,14 +11,14 @@ app.post('/', (req, res) => {
const loc = req.get('User-Agent').slice(3)
const time = req.get('X-Timestamp') || Date.now()
console.log(`Writing to database! ${loc}, ${time}, ${count}`)
res.sendStatus(200)
res.sendStatus(204)
fs.appendFile('db.csv', `${loc},${time},${count}\n`, function (err) {
if (err) throw err;
console.log('Saved!');
})
})
app.get('db.csv', (_, res) => res.sendFile('db.csv'))
app.get('/db.csv', (_, res) => res.sendFile(`${__dirname}/db.csv`))
app.listen(port, () => {
console.log(`Listening at http://localhost:${port}`)