Download app.js from yahiadevs/First-Ecommerce-WS: direct link, hf CLI and curl.
- Browser
- Download file 1.16 kB
-
https://huggingface.co/yahiadevs/First-Ecommerce-WS/resolve/main/app.js
- Command line
-
hf download hf://yahiadevs/First-Ecommerce-WS/app.js
-
curl -L -o app.js https://huggingface.co/yahiadevs/First-Ecommerce-WS/resolve/main/app.js
1.16 kB
| async function summarizeText() { | |
| const inputText = document.getElementById('inputText').value; | |
| const summaryDiv = document.getElementById('summary'); | |
| summaryDiv.innerHTML = "<em>Summarizing... Please wait.</em>"; | |
| // 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 = `<strong>Error:</strong> ${result.error}`; | |
| } else if (result[0] && result[0].summary_text) { | |
| // Display the summary | |
| summaryDiv.innerHTML = `<strong>Summary:</strong> ${result[0].summary_text}`; | |
| } else { | |
| summaryDiv.innerHTML = "<em>Unexpected response from API.</em>"; | |
| } | |
| } | |