Skip to content

Instantly share code, notes, and snippets.

Created May 22, 2022 04:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jonathanhudak/d42239bfbf8e92fd66268e59d0060360 to your computer and use it in GitHub Desktop.
Simple Deno Web Server for Generating QR Codes
import { qrcode } from "";
import { Application, Router } from "";
interface HTMLPageOptions {
body: string;
const makeHTMLPage = ({ body }: HTMLPageOptions) => `<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>QR Code Generator</title>
const router = new Router();
router.get("/", async (context) => {
const params = new URLSearchParams(context.request.url.searchParams);
const qrCode = params.get("qrCode");
let qrCodeImage = "";
if (qrCode) {
const src = await qrcode(qrCode);
qrCodeImage = `<img src="${src}" alt="qr code" />`;
context.response.body = makeHTMLPage({
body: `<form method="get" action="/">
<label for="qrCode">QR Code</label>
<input type="text" name="qrCode" id="qrCode" />
<button type="submit">Create QR Code</button>
<hr />
const app = new Application();
await app.listen({ port: 8002 });
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment