Spaces:
Paused
Paused
| <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> |