-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
31 lines (25 loc) · 782 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
const express = require('express')
const bodyParser = require('body-parser')
var path = require("path");
var QRCode = require('qrcode');
const { type } = require('os');
const app = express()
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, './public')));
app.post('/generate', (req, res) => {
var rec_url = String(req.query.url);
console.log(req.params['url'])
QRCode.toString("google.com", {type:'svg'}, (err, qr_str) => {
if (err) {
console.clear()
console.log(err)
}
console.clear()
console.log(qr_str)
res.send(qr_str)
})
})
app.get('/', function (req, res) {
res.sendFile(path.join(__dirname, './public/index.html'));
});
app.listen(8091)