update
Browse files- static/script.js +14 -30
static/script.js
CHANGED
@@ -1,38 +1,22 @@
|
|
1 |
document.addEventListener('DOMContentLoaded', () => {
|
2 |
-
const form = document.querySelector('
|
3 |
-
const
|
4 |
-
const output = document.querySelector('.text-gen-output');
|
5 |
|
6 |
-
form.addEventListener('submit', async (
|
7 |
-
|
8 |
|
9 |
-
const
|
|
|
|
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
method: 'GET',
|
15 |
-
headers: {
|
16 |
-
'Content-Type': 'application/json',
|
17 |
-
},
|
18 |
-
body: JSON.stringify({ textPrompt }),
|
19 |
-
});
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
// Update the output element with the predicted sepsis status and statement
|
27 |
-
output.textContent = `${user_input_statement}\n\n${statement}`;
|
28 |
-
} else {
|
29 |
-
output.textContent = 'Error: Unable to fetch prediction.';
|
30 |
-
}
|
31 |
-
} catch (error) {
|
32 |
-
output.textContent = 'Error: Something went wrong.';
|
33 |
-
}
|
34 |
-
} else {
|
35 |
-
output.textContent = 'Error: Text prompt cannot be empty.';
|
36 |
}
|
37 |
});
|
38 |
});
|
|
|
1 |
document.addEventListener('DOMContentLoaded', () => {
|
2 |
+
const form = document.querySelector('#sepsis-prediction form');
|
3 |
+
const result = document.querySelector('#sepsis-result');
|
|
|
4 |
|
5 |
+
form.addEventListener('submit', async (event) => {
|
6 |
+
event.preventDefault();
|
7 |
|
8 |
+
const formData = new FormData(form);
|
9 |
+
const urlParams = new URLSearchParams(formData);
|
10 |
+
const url = `/sepsis/predict?${urlParams.toString()}`;
|
11 |
|
12 |
+
try {
|
13 |
+
const response = await fetch(url);
|
14 |
+
const data = await response.json();
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
+
result.textContent = data.statement;
|
17 |
+
} catch (error) {
|
18 |
+
console.error('Error:', error);
|
19 |
+
result.textContent = 'An error occurred while processing the request.';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
}
|
21 |
});
|
22 |
});
|