// server.js
const express = require('express');
const QRCode = require('qrcode');
const app = express();
app.get('/:name', async (req, res) => {
const name = req.params.name;
const url = `https://love.tsonit.com/${name}`;
// Tạo mã QR PNG (hoặc SVG)
const qr = await QRCode.toDataURL(url, {
errorCorrectionLevel: 'H',
margin: 1,
color: {
dark: '#000000',
light: '#ffffff'
}
});
// HTML trả về
res.send(`
\<html\>
\<head\>\<title\>QR Love\</title\>\</head\>
\<body style="text-align:center; margin-top:50px;"\>
\<h2\>Quét để tỏ tình với: ${name}\</h2\>
\<img src="${qr}" style="width:300px; clip-path: path('M128 8c70 0 128 56 128 128s-128 128-128 128S0 206 0 136 58 8 128 8z');" /\>
\</body\>
\</html\>
`);
});
app.listen(3000, () => console.log('Running on http://localhost:3000'));