-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.js
36 lines (30 loc) · 877 Bytes
/
index.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
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const getLink = require('./getlink');
const port = 8000;
getLink.getCookieCsrf().then(() => {
app.set('view engine', 'ejs');
app.use(express.static('public'));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.get('/', (req, res) => {
res.render('home');
});
app.post('/', (req, res) => {
const linkFS = req.body.link;
getLink
.getLink(linkFS)
.then(linkDownload => {
console.log(`Link download: ${JSON.stringify(linkDownload)}`);
res.json(linkDownload);
})
.catch(err => {
console.log(`Get link error: ${JSON.stringify(err)}`);
res.send(err);
});
});
app.listen(port, () => {
console.log(`Server dang chay tren cong ${port}`);
});
});