-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
51 lines (43 loc) · 1.62 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Prediction Form</title>
</head>
<body>
<h2>Enter Data for Prediction</h2>
<form id="prediction-form">
<label for="heart-rate">Heart Rate:</label>
<input type="number" id="heart-rate" name="heart-rate" required><br><br>
<label for="calories">Calories:</label>
<input type="number" id="calories" name="calories" required><br><br>
<label for="trimester">Trimester:</label>
<input type="number" id="trimester" name="trimester" required><br><br>
<label for="sleep-time">Sleep Time:</label>
<input type="number" id="sleep-time" name="sleep-time" required><br><br>
<button type="submit">Predict</button>
</form>
<div id="prediction-result"></div>
<script>
document.getElementById('prediction-form').addEventListener('submit', function(event) {
event.preventDefault();
const formData = new FormData(this);
fetch('/predict', {
method: 'POST',
body: JSON.stringify(Object.fromEntries(formData)),
headers: {
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => {
document.getElementById('prediction-result').innerText = 'Prediction: ' + data.prediction;
})
.catch(error => {
console.error('Error:', error);
});
});
</script>
</body>
</html>