-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
app.html
57 lines (49 loc) · 1.27 KB
/
app.html
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
<!DOCTYPE html>
<html>
<head>
<title>Random Number Generator</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script defer type="module">
import {
html,
render,
} from "https://unpkg.com/htm/preact/index.mjs?module";
import { useState } from "https://unpkg.com/preact/hooks/dist/hooks.module.js?module";
function App() {
const [number, setNumber] = useState(0);
return html`
<div class="container">
<h1>NENSS</h1>
<p>
<button
onClick=${async () => {
const response = await fetch("/randomNumber");
setNumber(await response.json());
}}
>
Get random number
</button>
</p>
<p>${number}</p>
</div>
`;
}
render(html`<${App} />`, document.body);
</script>
<style>
* {
margin: 0;
}
.container {
background-color: lightsalmon;
gap: 10px;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
</style>
</head>
<body></body>
</html>