-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (25 loc) · 696 Bytes
/
index.js
File metadata and controls
33 lines (25 loc) · 696 Bytes
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
import express from "express";
import bodyParser from "body-parser";
import qr from "qr-image";
import fs from "fs";
import { dirname } from "path";
import { fileURLToPath } from "url";
const _dirname = dirname(fileURLToPath(import.meta.url));
const app = express();
const port = 3000;
app.use(express.static("public"));
app.use(bodyParser.urlencoded({extended:true}));
app.get("/",(req,res)=>{
res.render("index.ejs");
})
app.post("/submit",(req,res)=>{
var qr_svg = qr.image(req.body["url"]);
qr_svg.pipe(fs.createWriteStream("public/url_img1.png"));
var img = true;
res.render("index.ejs",
{img:img}
);
});
app.listen(port,()=>{
console.log(`running on ${port}.`);
});