Spaces:
Sleeping
Sleeping
Update index.html
Browse files- index.html +130 -32
index.html
CHANGED
|
@@ -1,63 +1,130 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html>
|
| 3 |
<head>
|
| 4 |
-
<title>
|
| 5 |
<style>
|
| 6 |
-
body { font-family: Arial, sans-serif; text-align: center; margin-top:
|
| 7 |
.container {
|
| 8 |
-
width:
|
| 9 |
-
max-width:
|
| 10 |
margin: 0 auto;
|
| 11 |
padding: 20px;
|
| 12 |
border: 1px solid #ccc;
|
| 13 |
border-radius: 10px;
|
| 14 |
background-color: #fff;
|
| 15 |
-
box-shadow: 0 4px
|
| 16 |
}
|
| 17 |
-
h1 { color: #
|
| 18 |
-
p { color: #666; }
|
| 19 |
-
#
|
| 20 |
button {
|
| 21 |
padding: 10px 20px;
|
| 22 |
-
background-color: #
|
| 23 |
color: white;
|
| 24 |
border: none;
|
| 25 |
border-radius: 5px;
|
| 26 |
cursor: pointer;
|
| 27 |
transition: background-color 0.3s;
|
|
|
|
| 28 |
}
|
| 29 |
-
button:hover {
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
}
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
padding: 15px;
|
| 37 |
border-radius: 8px;
|
|
|
|
| 38 |
}
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
color: #007bff;
|
| 41 |
-
font-size: 1.2em;
|
| 42 |
-
margin-top: 10px;
|
| 43 |
}
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
</style>
|
| 47 |
</head>
|
| 48 |
<body>
|
| 49 |
<div class="container">
|
| 50 |
-
<h1>
|
| 51 |
-
<p>Sube un
|
| 52 |
-
|
| 53 |
-
<
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
</div>
|
|
|
|
| 57 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
async function uploadFile() {
|
| 59 |
const fileInput = document.getElementById('file-upload');
|
| 60 |
const file = fileInput.files[0];
|
|
|
|
|
|
|
|
|
|
| 61 |
if (!file) {
|
| 62 |
alert('Por favor, selecciona un archivo.');
|
| 63 |
return;
|
|
@@ -67,29 +134,60 @@
|
|
| 67 |
formData.append('file', file);
|
| 68 |
|
| 69 |
document.getElementById('loading').style.display = 'block';
|
| 70 |
-
document.getElementById('summary-result').innerHTML = '';
|
| 71 |
|
| 72 |
try {
|
| 73 |
const response = await fetch('/summarize', {
|
| 74 |
method: 'POST',
|
| 75 |
body: formData
|
| 76 |
});
|
|
|
|
| 77 |
const data = await response.json();
|
| 78 |
|
| 79 |
if (response.ok) {
|
| 80 |
-
const
|
|
|
|
|
|
|
|
|
|
| 81 |
const ul = document.createElement('ul');
|
|
|
|
| 82 |
data.summary.forEach(point => {
|
| 83 |
const li = document.createElement('li');
|
| 84 |
-
|
|
|
|
| 85 |
ul.appendChild(li);
|
| 86 |
});
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
} else {
|
| 89 |
-
|
|
|
|
| 90 |
}
|
| 91 |
} catch (error) {
|
| 92 |
-
|
| 93 |
} finally {
|
| 94 |
document.getElementById('loading').style.display = 'none';
|
| 95 |
}
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html>
|
| 3 |
<head>
|
| 4 |
+
<title>Analizador de Documentos Inmobiliarios y JAC</title>
|
| 5 |
<style>
|
| 6 |
+
body { font-family: Arial, sans-serif; text-align: center; margin-top: 20px; background-color: #f4f4f9; color: #333; }
|
| 7 |
.container {
|
| 8 |
+
width: 90%;
|
| 9 |
+
max-width: 1000px;
|
| 10 |
margin: 0 auto;
|
| 11 |
padding: 20px;
|
| 12 |
border: 1px solid #ccc;
|
| 13 |
border-radius: 10px;
|
| 14 |
background-color: #fff;
|
| 15 |
+
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
| 16 |
}
|
| 17 |
+
h1 { color: #007bff; }
|
| 18 |
+
p { color: #666; margin-bottom: 20px;}
|
| 19 |
+
#upload-section { margin: 20px 0; border-bottom: 1px solid #eee; padding-bottom: 20px; }
|
| 20 |
button {
|
| 21 |
padding: 10px 20px;
|
| 22 |
+
background-color: #28a745;
|
| 23 |
color: white;
|
| 24 |
border: none;
|
| 25 |
border-radius: 5px;
|
| 26 |
cursor: pointer;
|
| 27 |
transition: background-color 0.3s;
|
| 28 |
+
margin-left: 10px;
|
| 29 |
}
|
| 30 |
+
button:hover { background-color: #218838; }
|
| 31 |
+
|
| 32 |
+
#loading {
|
| 33 |
+
color: #007bff;
|
| 34 |
+
font-size: 1.2em;
|
| 35 |
+
margin-top: 15px;
|
| 36 |
+
display: none;
|
| 37 |
}
|
| 38 |
+
|
| 39 |
+
.results-container {
|
| 40 |
+
display: flex;
|
| 41 |
+
justify-content: space-between;
|
| 42 |
+
margin-top: 30px;
|
| 43 |
+
text-align: left;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
.result-panel {
|
| 47 |
+
width: 48%; /* Divide el espacio casi a la mitad */
|
| 48 |
padding: 15px;
|
| 49 |
border-radius: 8px;
|
| 50 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
| 51 |
}
|
| 52 |
+
|
| 53 |
+
#summary-display {
|
| 54 |
+
background-color: #e6f7ff; /* Azul claro para el resumen */
|
| 55 |
+
border: 1px solid #b3e0ff;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
#json-display {
|
| 59 |
+
background-color: #fff0e6; /* Naranja claro para el JSON */
|
| 60 |
+
border: 1px solid #ffccb3;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
h2 {
|
| 64 |
+
border-bottom: 2px solid #ccc;
|
| 65 |
+
padding-bottom: 5px;
|
| 66 |
+
margin-top: 0;
|
| 67 |
color: #007bff;
|
|
|
|
|
|
|
| 68 |
}
|
| 69 |
+
|
| 70 |
+
ul { list-style-type: none; padding-left: 0; }
|
| 71 |
+
li { margin-bottom: 12px; line-height: 1.4; border-bottom: 1px dotted #ccc; padding-bottom: 5px;}
|
| 72 |
+
li strong { color: #333; }
|
| 73 |
+
|
| 74 |
+
pre {
|
| 75 |
+
background-color: #f8f8f8;
|
| 76 |
+
padding: 10px;
|
| 77 |
+
border-radius: 5px;
|
| 78 |
+
overflow-x: auto;
|
| 79 |
+
white-space: pre-wrap;
|
| 80 |
+
word-wrap: break-word;
|
| 81 |
+
font-size: 0.9em;
|
| 82 |
+
border: 1px solid #ddd;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
</style>
|
| 86 |
</head>
|
| 87 |
<body>
|
| 88 |
<div class="container">
|
| 89 |
+
<h1>Análisis Experto de Documentos</h1>
|
| 90 |
+
<p>Sube un Certificado de Tradición y Libertad (CTL) o un documento de Junta de Acción Comunal (JAC).</p>
|
| 91 |
+
|
| 92 |
+
<div id="upload-section">
|
| 93 |
+
<input type="file" id="file-upload" accept=".txt,.pdf">
|
| 94 |
+
<button onclick="uploadFile()">Analizar Documento</button>
|
| 95 |
+
</div>
|
| 96 |
+
|
| 97 |
+
<div id="loading">Procesando documento, esto puede tardar si el PDF es escaneado...</div>
|
| 98 |
+
|
| 99 |
+
<div class="results-container">
|
| 100 |
+
<div id="summary-display" class="result-panel">
|
| 101 |
+
<h2>✅ Resumen de Puntos Clave</h2>
|
| 102 |
+
<div id="summary-result">Aquí se mostrará el análisis estructurado de los 7 puntos.</div>
|
| 103 |
+
</div>
|
| 104 |
+
|
| 105 |
+
<div id="json-display" class="result-panel">
|
| 106 |
+
<h2>💻 Estructura JSON Completa</h2>
|
| 107 |
+
<pre id="json-result">El JSON completo se mostrará aquí.</pre>
|
| 108 |
+
</div>
|
| 109 |
+
</div>
|
| 110 |
</div>
|
| 111 |
+
|
| 112 |
<script>
|
| 113 |
+
// Función para limpiar el contenido anterior
|
| 114 |
+
function resetResults() {
|
| 115 |
+
document.getElementById('loading').style.display = 'none';
|
| 116 |
+
document.getElementById('summary-result').innerHTML = '';
|
| 117 |
+
document.getElementById('json-result').textContent = '';
|
| 118 |
+
document.getElementById('summary-display').style.display = 'none';
|
| 119 |
+
document.getElementById('json-display').style.display = 'none';
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
async function uploadFile() {
|
| 123 |
const fileInput = document.getElementById('file-upload');
|
| 124 |
const file = fileInput.files[0];
|
| 125 |
+
|
| 126 |
+
resetResults();
|
| 127 |
+
|
| 128 |
if (!file) {
|
| 129 |
alert('Por favor, selecciona un archivo.');
|
| 130 |
return;
|
|
|
|
| 134 |
formData.append('file', file);
|
| 135 |
|
| 136 |
document.getElementById('loading').style.display = 'block';
|
|
|
|
| 137 |
|
| 138 |
try {
|
| 139 |
const response = await fetch('/summarize', {
|
| 140 |
method: 'POST',
|
| 141 |
body: formData
|
| 142 |
});
|
| 143 |
+
|
| 144 |
const data = await response.json();
|
| 145 |
|
| 146 |
if (response.ok) {
|
| 147 |
+
const summaryDiv = document.getElementById('summary-result');
|
| 148 |
+
const jsonPre = document.getElementById('json-result');
|
| 149 |
+
|
| 150 |
+
// 1. Mostrar el Resumen/Lista
|
| 151 |
const ul = document.createElement('ul');
|
| 152 |
+
// El backend devuelve 'summary' como una lista de strings formateados: ["**Campo:** Valor"]
|
| 153 |
data.summary.forEach(point => {
|
| 154 |
const li = document.createElement('li');
|
| 155 |
+
// Usamos innerHTML para renderizar el formato ** negrita **
|
| 156 |
+
li.innerHTML = point;
|
| 157 |
ul.appendChild(li);
|
| 158 |
});
|
| 159 |
+
summaryDiv.appendChild(ul);
|
| 160 |
+
|
| 161 |
+
// 2. Mostrar el JSON completo
|
| 162 |
+
// Los datos reales del JSON están anidados dentro de los strings del resumen.
|
| 163 |
+
// Para mostrar el JSON original completo, necesitaríamos que el backend devuelva
|
| 164 |
+
// la lista 'summary' Y el objeto JSON original.
|
| 165 |
+
// Por simplicidad, reconstruimos o asumimos el JSON original
|
| 166 |
+
// ya que el backend lo convierte a 'summary_list' (ver app.py)
|
| 167 |
+
|
| 168 |
+
// Para mostrar el objeto que se envió desde el backend:
|
| 169 |
+
const rawJson = {};
|
| 170 |
+
data.summary.forEach(item => {
|
| 171 |
+
const parts = item.split(':** ');
|
| 172 |
+
if (parts.length === 2) {
|
| 173 |
+
// Extrae la clave limpiando las negritas (**)
|
| 174 |
+
let key = parts[0].replace(/\*\*/g, '').trim();
|
| 175 |
+
key = key.charAt(0).toLowerCase() + key.slice(1).replace(/\s/g, '_');
|
| 176 |
+
rawJson[key] = parts[1].trim();
|
| 177 |
+
}
|
| 178 |
+
});
|
| 179 |
+
|
| 180 |
+
jsonPre.textContent = JSON.stringify(rawJson, null, 4);
|
| 181 |
+
|
| 182 |
+
document.getElementById('summary-display').style.display = 'block';
|
| 183 |
+
document.getElementById('json-display').style.display = 'block';
|
| 184 |
+
|
| 185 |
} else {
|
| 186 |
+
// Mostrar error del servidor
|
| 187 |
+
document.getElementById('summary-result').innerHTML = `Error: ${data.error}`;
|
| 188 |
}
|
| 189 |
} catch (error) {
|
| 190 |
+
document.getElementById('summary-result').innerHTML = `Ocurrió un error de conexión con el servidor.`;
|
| 191 |
} finally {
|
| 192 |
document.getElementById('loading').style.display = 'none';
|
| 193 |
}
|