document.getElementById("detectBtn").onclick = async function() {
const fileInput = document.getElementById("csvInput");
if (!fileInput.files.length) {
alert("Select a CSV file.");
return;
}
const formData = new FormData();
formData.append("file", fileInput.files[0]);
const res = await fetch("/detect_fraud", {
method: "POST",
body: formData
});
const data = await res.json();
document.getElementById("fraudResult").textContent = data.result;
};
</script>