-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
30 lines (29 loc) · 1.1 KB
/
index.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
<html>
<head>
<title>Fortune Teller</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
</head>
<body>
<div class="container mt-5">
<h1 class="text-center mb-4">Fortune Teller</h1>
<p class="text-center mb-4">Click the button below to get your fortune:</p>
<form onsubmit="getFortune(); return false;">
<button type="submit" class="btn btn-primary btn-block">Get Fortune</button>
</form>
<div id="fortune" class="card mt-5 mx-auto text-center">
<div class="card-body">
Your fortune will appear here.
</div>
</div>
</div>
<script>
async function getFortune() {
const response = await fetch('http://localhost:3000/fortune');
const data = await response.json();
const fortune = data.fortune;
const fortuneEl = document.getElementById('fortune');
fortuneEl.innerHTML = fortune;
}
</script>
</body>
</html>