-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
96 lines (90 loc) · 2.66 KB
/
Copy pathindex.html
File metadata and controls
96 lines (90 loc) · 2.66 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html>
<html lang="uk">
<head>
<meta charset="UTF-8">
<title>Стартова сторінка</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 40px;
background: #f4f4f9;
color: #333;
}
h1 {
text-align: center;
}
.container {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 20px;
max-width: 800px;
margin: 0 auto;
}
.card {
background: white;
padding: 20px;
border-radius: 12px;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.card h2 {
margin-top: 0;
font-size: 18px;
color: #555;
}
button {
display: block;
margin: 20px auto;
padding: 10px 20px;
border: none;
border-radius: 8px;
background: #4a90e2;
color: white;
cursor: pointer;
font-size: 16px;
}
button:hover {
background: #357abd;
}
</style>
</head>
<body>
<h1>Дані з API</h1>
<div class="container">
<div class="card"><h2>Поле 1</h2><p id="field1">Завантаження...</p></div>
<div class="card"><h2>Поле 2</h2><p id="field2">Завантаження...</p></div>
<div class="card"><h2>Поле 3</h2><p id="field3">Завантаження...</p></div>
<div class="card"><h2>Поле 4</h2><p id="field4">Завантаження...</p></div>
<div class="card"><h2>Поле 5</h2><p id="field5">Завантаження...</p></div>
</div>
<button onclick="loadData()">Оновити дані</button>
<script>
async function loadData() {
try {
// Заміни ці шляхи на свої API з index.ts
const endpoints = [
"/api/today",
"/api/d6",
"/api/now",
"/api/whoami",
"/api/weekend",
];
const results = await Promise.all(endpoints.map(url =>
fetch(url).then(r => r.text())
));
// Запис у поля
document.getElementById("field1").innerText = results[0];
document.getElementById("field2").innerText = results[1];
document.getElementById("field3").innerText = results[2];
document.getElementById("field4").innerText = results[3];
document.getElementById("field5").innerText = results[4];
} catch (err) {
console.error("Помилка завантаження:", err);
}
}
// Автооновлення раз на 10 сек
setInterval(loadData, 10000);
// Початкове завантаження
loadData();
</script>
</body>
</html>