-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
59 lines (56 loc) · 2 KB
/
index.html
File metadata and controls
59 lines (56 loc) · 2 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Network Traffic Dashboard</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<h1>Network Traffic Dashboard</h1>
</header>
<main>
<section id="dashboard">
<div id="chart-container">
<canvas id="trafficChart"></canvas>
<p>Drop the file containing dataset of the captured packets and their specifics</p>
<div class="upload-container">
<label for="file-input" class="upload-box">
<span>Click to Upload a File</span>
<input type="file" id="file-input" class="file-input" />
</label>
</div>
</div>
</section>
</main>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
document.getElementById('file-input').addEventListener('change', async (event) => {
const file = event.target.files[0];
if (!file) {
alert('Please select a file!');
return;
}
const formData = new FormData();
formData.append('file', file);
try {
const response = await fetch('http://127.0.0.1:5000/upload', {
method: 'POST',
body: formData,
});
const result = await response.json();
if (response.ok) {
alert('File uploaded successfully and is being processed!');
console.log(result.message);
} else {
alert('File upload failed: ' + result.message);
}
} catch (error) {
console.error('Error:', error);
alert('An error occurred while uploading the file.');
}
});
</script>
</body>
</html>