-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
48 lines (42 loc) · 1.34 KB
/
index.html
File metadata and controls
48 lines (42 loc) · 1.34 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NetSpeedTest</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<div class="container">
<h1>Internet Speed Test</h1>
<button id="speedTestBtn" onclick="getSpeedTest()">Check Speed</button>
<p id="result"></p>
</div>
<script>
async function getSpeedTest() {
const button = document.getElementById('speedTestBtn');
const result = document.getElementById('result');
// Disable the button and show loading message
button.disabled = true;
result.innerText = "Testing...";
// https://netspeedtest-1.onrender.com/
//
try {
const response = await fetch('http://localhost:5000/api/speed-test');
if (!response.ok) throw new Error("Network response was not ok");
const data = await response.json();
result.innerHTML = `
Download Speed: ${data.download_speed} Mbps <br>
Upload Speed: ${data.upload_speed} Mbps <br>
Ping: ${data.ping} ms
`;
} catch (error) {
console.error('Error:', error);
result.innerText = "Error fetching speed data.";
} finally {
button.disabled = false;
}
}
</script>
</body>
</html>