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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// View at https://prindom-expresshtmlexample.express.val.run/?name=Dominik
export async function expressHTMLExample(
req: express.Request,
res: express.Response,
) {
let getButton = (label = "Label", id) => {
let button = `<div class='w-fit p-2'>
<a
class="group relative inline-block focus:outline-none focus:ring"
href="/download"
>
<span
class="absolute inset-0 translate-x-0 translate-y-0 bg-yellow-300 transition-transform group-hover:translate-y-1.5 group-hover:translate-x-1.5"
></span>
<span
class="relative inline-block border-2 border-current px-8 py-3 text-sm font-bold uppercase tracking-widest"
>
${label}
</span>
</a></div>
`;
return button;
};
let progressbar = `
<div class='p-4'>
<span id="ProgressLabel" class="sr-only">Loading</span>
<span
role="progressbar"
aria-labelledby="ProgressLabel"
aria-valuenow="75"
class="relative block rounded-full bg-gray-200"
>
<span
class="absolute inset-0 flex items-center justify-center text-[10px]/4"
>
<span class="font-bold text-white"> 75% </span>
</span>
<span
class="block h-4 rounded-full bg-indigo-600 text-center"
style="width: 75%"
>
</span>
</span>
</div>
`;
let html = `
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<div class="container mx-auto px-4">
<div class='w-full px-3'>
<h1 class="text-3xl font-bold underline text-center p-3">
hello ${req.query.name || req.body.name}
</h1>
</div>
<div class="flex items-center flex-col">
${getButton("option 1", 1)}
${getButton("option 2", 2)}
</div>
${progressbar}
${progressbar}
</div>
</body>
</html>
`;
return res.send(html);
}