Spaces:
Runtime error
Runtime error
File size: 1,212 Bytes
b83473a 97030c2 b83473a 52c3d5f 97030c2 52c3d5f 97030c2 52c3d5f b83473a 97030c2 b83473a 97030c2 b83473a |
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 |
"use strict";
const form = document.getElementById("predictionForm");
const predictionResults = document.getElementById("predictionResults");
form.addEventListener("submit", async (e) => {
e.preventDefault();
const sequence = document.getElementById("sequence").value;
const smiles = document.getElementById("smiles").value;
if (!sequence || !smiles) {
alert("Please enter both sequence and SMILES");
return;
}
if (predictionResults.classList.contains("hidden")) {
// unhide the results div by removing the class hidden
predictionResults.classList.remove("hidden");
predictionResults.classList.add("box");
}
// loader until the results are fetched
predictionResults.innerHTML = `
<div class="loader"></div>
`
const response = await fetch("/api/predict", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
},
body: JSON.stringify({ sequence, smiles }),
});
const data = await response.json();
// display the results
predictionResults.innerHTML = `
<h2>Prediction Results</h2>
<p><strong>Km:</strong> ${data.Km}</p>
<p><strong>Kcat:</strong> ${data.Kcat}</p>
<p><strong>Vmax:</strong> ${data.Vmax}</p>`;
});
|