-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_input.html
64 lines (59 loc) · 1.88 KB
/
user_input.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
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Run Algorithm</title>
</head>
<body>
<h1>Run Algorithm</h1>
<form id="algorithmForm">
<label for="inputData">Enter input data (comma-separated):</label>
<input type="text" id="inputData" name="inputData" required />
<button type="submit">Submit</button>
</form>
<div id="result"></div>
<script>
document
.getElementById("algorithmForm")
.addEventListener("submit", function (event) {
event.preventDefault();
console.log(127818971298);
// Get the input data from the form
const inputData = document
.getElementById("inputData")
.value.split(",")
.map(Number);
console.log("here");
// Send the input data to the server using Fetch
fetch("http://localhost:8080/run-algorithm", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(inputData),
})
.then((response) => {
if (!response.ok) {
throw new Error(HTTP error! status: ${response.status});
}
return response.json();
})
.then((data) => {
// Display the result
document.getElementById(
"result"
).innerText = Probability of PCOS: ${
data.probability_pcos * 100
}%;
})
.catch((error) => {
console.error("Error:", error);
document.getElementById(
"result"
).innerText = An error occurred: ${error.message};
});
});
</script>
</body>
</html>