Public
Express
ramkarthik-generateqr.express.val.run
October 23, 2023
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// fetch("https://api.val.town/v1/express/ramkarthik.GenerateQR?url={url}"
export async function GenerateQR(req, res) {
const url = req.query.url;
res.set("Content-Type", "text/html");
if (!url) {
res.send(
"<html><body>Not a valid URL - " + JSON.stringify(req.query) +
"</body></html>",
);
}
const { qrcode } = await import("https://deno.land/x/qrcode/mod.ts");
const base64Image = await qrcode(url);
res.send(
`<html><body><img src=${base64Image} height="100px" width="100px" /><p style="font-size:10px">QR Code generated using <a href="https://val.town">val.town</a></p><p style="font-size:10px">Built with 💗 by <a href="https://twitter.com/Ramkarthik">
);
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023