async function summarizeText() { const inputText = document.getElementById('inputText').value; const summaryDiv = document.getElementById('summary'); summaryDiv.innerHTML = "Summarizing... Please wait."; // Now call YOUR backend endpoint, not Hugging Face's directly const response = await fetch("http://localhost:5000/summarize", { // Your server's address method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ text: inputText }), // Send data to your server }); const result = await response.json(); // Display the result if (result.error) { // Handle errors (e.g., model is loading) summaryDiv.innerHTML = `Error: ${result.error}`; } else if (result[0] && result[0].summary_text) { // Display the summary summaryDiv.innerHTML = `Summary: ${result[0].summary_text}`; } else { summaryDiv.innerHTML = "Unexpected response from API."; } }