Spaces:
Paused
Paused
File size: 2,977 Bytes
23004ee |
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Summarize | TaskBot v1+ AI</title>
<link rel="Icon" href="TaskBot logo.png">
</head>
<style>
body {
background-color: #2f2f2f;
font-family: Arial, sans-serif;
color: white;
margin: 0;
padding: 20px;
}
h1 {
text-align: center;
}
textarea {
width: 100%;
height: 300px;
}
button {
width: 100px;
height: 50px;
text-align: center;
float: right;
}
small {
display: block;
text-align: center;
color: gray
}
</style>
<body>
<h1>Summarizer</h1>
<small>Powered by gemini-2.0-flash</small><br><br>
<textarea name="question" id="question" placeholder="Write your text here to summarize..."></textarea><br><br><br>
<button onclick=answer() id="answer_button">Start Summarizing</button>
<label for="type">Summarize to: </label>
<select name="type" id="type">
<option value="points">Points</option>
<option value="para">Paragraph</option>
</select><br><br><br>
<label for="lines_points">Minimum Lines/Points</label>
<input type="number" id="lines_points"><br><br><br>
<textarea name="answer" id="answer" placeholder="Summary will be displayed here..."></textarea>
<script>
async function answer() {
document.getElementById("answer_button").disabled = true
const userInput = document.getElementById('question').value;
if (userInput.trim() === '') return;
const question = userInput;
const type = document.getElementById("type").value;
const num_of_lines_points = document.getElementById("lines_points").value;
try {
const response = await fetch("/summarize", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: new URLSearchParams({ question: question, type: type, num_of_lines_points: num_of_lines_points })
});
const data = await response.json();
const answer_area = document.getElementById("answer");
if (data.answer) {
aiResponse = data.answer;
} else if (data.error) {
aiResponse = "Error: " + data.error;
}
answer_area.value = aiResponse
} catch (err) {
console.error("Fetch Error:", err);
document.getElementById("answer").value = err;
}
document.getElementById("answer_button").disabled = false
}
</script>
</body>
</html> |