Upload 3 files
Browse files- app.js +27 -0
- app.py +0 -0
- index.html +27 -0
app.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
async function summarizeText() {
|
| 2 |
+
const inputText = document.getElementById('inputText').value;
|
| 3 |
+
const summaryDiv = document.getElementById('summary');
|
| 4 |
+
summaryDiv.innerHTML = "<em>Summarizing... Please wait.</em>";
|
| 5 |
+
|
| 6 |
+
// Now call YOUR backend endpoint, not Hugging Face's directly
|
| 7 |
+
const response = await fetch("http://localhost:5000/summarize", { // Your server's address
|
| 8 |
+
method: "POST",
|
| 9 |
+
headers: {
|
| 10 |
+
"Content-Type": "application/json",
|
| 11 |
+
},
|
| 12 |
+
body: JSON.stringify({ text: inputText }), // Send data to your server
|
| 13 |
+
});
|
| 14 |
+
|
| 15 |
+
const result = await response.json();
|
| 16 |
+
|
| 17 |
+
// Display the result
|
| 18 |
+
if (result.error) {
|
| 19 |
+
// Handle errors (e.g., model is loading)
|
| 20 |
+
summaryDiv.innerHTML = `<strong>Error:</strong> ${result.error}`;
|
| 21 |
+
} else if (result[0] && result[0].summary_text) {
|
| 22 |
+
// Display the summary
|
| 23 |
+
summaryDiv.innerHTML = `<strong>Summary:</strong> ${result[0].summary_text}`;
|
| 24 |
+
} else {
|
| 25 |
+
summaryDiv.innerHTML = "<em>Unexpected response from API.</em>";
|
| 26 |
+
}
|
| 27 |
+
}
|
app.py
ADDED
|
File without changes
|
index.html
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<title>Text Summarizer</title>
|
| 6 |
+
<style>
|
| 7 |
+
body { font-family: sans-serif; max-width: 700px; margin: 50px auto; }
|
| 8 |
+
textarea { width: 100%; height: 150px; }
|
| 9 |
+
button { padding: 10px 20px; margin-top: 10px; }
|
| 10 |
+
#summary { margin-top: 20px; padding: 15px; background-color: #f0f0f0; }
|
| 11 |
+
</style>
|
| 12 |
+
</head>
|
| 13 |
+
<body>
|
| 14 |
+
<h1>AI Text Summarizer</h1>
|
| 15 |
+
<p>Enter some text below and I'll summarize it for you.</p>
|
| 16 |
+
|
| 17 |
+
<textarea id="inputText" placeholder="Paste your long article here..."></textarea>
|
| 18 |
+
<br>
|
| 19 |
+
<button onclick="summarizeText()">Summarize</button>
|
| 20 |
+
|
| 21 |
+
<div id="summary"></div>
|
| 22 |
+
|
| 23 |
+
<script>
|
| 24 |
+
<script type ="module" src = "app.js"></script>
|
| 25 |
+
</script>
|
| 26 |
+
</body>
|
| 27 |
+
</html>
|