-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
34 lines (31 loc) · 877 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
var express = require('express')
var app = express()
var bodyParser = require('body-parser');
var fs = require('fs')
var rs = require('randomstring')
var findRemoveSync = require('find-remove')
var name = ""
var upperBound = '1gb';
var port = process.env.PORT || 8000;
console.log(port);
var result = findRemoveSync(__dirname + '/download', {
age: {
seconds: 3600
},
extensions: '.ics'
})
app.listen(port)
app.use(express.static(__dirname))
app.use(bodyParser.urlencoded({ extended: true}));
app.use(bodyParser.json());
app.post('/cal', function(req, resp) {
var cat = req.body.data.split("\\n")
name = "carlendar" + req.body.id
fs.writeFile('download/' + name + '.ics', cat.join("\n"), (err) => {
console.log(name)
})
resp.sendStatus(200)
});
app.get('/download', function(req, res) {
res.send('download/carlendar');
});