Spaces:
Sleeping
Sleeping
| <html> | |
| <head> | |
| <title>Resumidor de Documentos</title> | |
| <style> | |
| body { font-family: Arial, sans-serif; text-align: center; margin-top: 50px; background-color: #f4f4f9; } | |
| .container { | |
| width: 80%; | |
| max-width: 800px; | |
| margin: 0 auto; | |
| padding: 20px; | |
| border: 1px solid #ccc; | |
| border-radius: 10px; | |
| background-color: #fff; | |
| box-shadow: 0 4px 8px rgba(0,0,0,0.1); | |
| } | |
| h1 { color: #333; } | |
| p { color: #666; } | |
| #file-upload { margin: 20px 0; } | |
| button { | |
| padding: 10px 20px; | |
| background-color: #007bff; | |
| color: white; | |
| border: none; | |
| border-radius: 5px; | |
| cursor: pointer; | |
| transition: background-color 0.3s; | |
| } | |
| button:hover { | |
| background-color: #0056b3; | |
| } | |
| #summary-result { | |
| margin-top: 20px; | |
| text-align: left; | |
| background-color: #e9ecef; | |
| padding: 15px; | |
| border-radius: 8px; | |
| } | |
| #loading { | |
| color: #007bff; | |
| font-size: 1.2em; | |
| margin-top: 10px; | |
| } | |
| ul { list-style-type: disc; padding-left: 20px; } | |
| li { margin-bottom: 10px; line-height: 1.5; } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="container"> | |
| <h1>Resumidor de Documentos con IA</h1> | |
| <p>Sube un archivo de texto (.txt) o PDF para generar un resumen de 5 puntos clave.</p> | |
| <input type="file" id="file-upload" accept=".txt,.pdf"> | |
| <button onclick="uploadFile()">Generar Resumen</button> | |
| <div id="loading" style="display: none;">Cargando...</div> | |
| <div id="summary-result"></div> | |
| </div> | |
| <script> | |
| async function uploadFile() { | |
| const fileInput = document.getElementById('file-upload'); | |
| const file = fileInput.files[0]; | |
| if (!file) { | |
| alert('Por favor, selecciona un archivo.'); | |
| return; | |
| } | |
| const formData = new FormData(); | |
| formData.append('file', file); | |
| document.getElementById('loading').style.display = 'block'; | |
| document.getElementById('summary-result').innerHTML = ''; | |
| try { | |
| const response = await fetch('/summarize', { | |
| method: 'POST', | |
| body: formData | |
| }); | |
| const data = await response.json(); | |
| if (response.ok) { | |
| const resultDiv = document.getElementById('summary-result'); | |
| const ul = document.createElement('ul'); | |
| data.summary.forEach(point => { | |
| const li = document.createElement('li'); | |
| li.textContent = point; | |
| ul.appendChild(li); | |
| }); | |
| resultDiv.appendChild(ul); | |
| } else { | |
| alert('Error: ' + data.error); | |
| } | |
| } catch (error) { | |
| alert('Ocurrió un error al conectar con el servidor.'); | |
| } finally { | |
| document.getElementById('loading').style.display = 'none'; | |
| } | |
| } | |
| </script> | |
| </body> | |
| </html> |