Spaces:
Sleeping
Sleeping
Update index.html
Browse files- index.html +41 -50
index.html
CHANGED
|
@@ -1,55 +1,46 @@
|
|
| 1 |
-
<
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
</head>
|
| 8 |
-
<body class="bg-slate-900 text-slate-100 min-h-screen p-8">
|
| 9 |
-
<div class="max-w-4xl mx-auto">
|
| 10 |
-
<h1 class="text-4xl font-bold mb-8 text-indigo-400">🔍 PragmaLens AI</h1>
|
| 11 |
-
|
| 12 |
-
<div class="bg-slate-800 p-6 rounded-xl border border-slate-700 shadow-xl">
|
| 13 |
-
<input type="file" id="pdfInput" class="block w-full mb-4 text-sm text-slate-400 file:bg-indigo-600 file:px-4 file:py-2 file:rounded-lg cursor-pointer">
|
| 14 |
-
<textarea id="textInput" class="w-full bg-slate-950 p-4 rounded-lg border border-slate-700 h-32" placeholder="Introduce el texto aquí..."></textarea>
|
| 15 |
-
<button id="analyzeBtn" class="w-full mt-4 bg-indigo-600 hover:bg-indigo-500 py-3 rounded-lg font-bold transition">Ejecutar Auditoría</button>
|
| 16 |
-
</div>
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
<div id="content" class="text-sm space-y-4"></div>
|
| 21 |
-
</div>
|
| 22 |
-
</div>
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
data = await res.json();
|
| 47 |
}
|
| 48 |
-
|
| 49 |
-
} catch (e) {
|
| 50 |
-
content.innerText = "Error: " + e.message;
|
| 51 |
}
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
<script>
|
| 2 |
+
document.getElementById('analyzeBtn').onclick = async () => {
|
| 3 |
+
const resDiv = document.getElementById('results');
|
| 4 |
+
const content = document.getElementById('content');
|
| 5 |
+
const file = document.getElementById('pdfInput').files[0];
|
| 6 |
+
const text = document.getElementById('textInput').value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
resDiv.classList.remove('hidden');
|
| 9 |
+
content.innerHTML = "<div class='animate-pulse text-indigo-400'>Analizando discurso...</div>";
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
try {
|
| 12 |
+
let data;
|
| 13 |
+
if (file) {
|
| 14 |
+
const fd = new FormData();
|
| 15 |
+
fd.append('file', file);
|
| 16 |
+
const res = await fetch('/analyze_pdf', {method: 'POST', body: fd});
|
| 17 |
+
data = await res.json();
|
| 18 |
+
} else {
|
| 19 |
+
const res = await fetch('/analyze', {
|
| 20 |
+
method: 'POST', headers: {'Content-Type': 'application/json'},
|
| 21 |
+
body: JSON.stringify({text})
|
| 22 |
+
});
|
| 23 |
+
data = await res.json();
|
| 24 |
+
}
|
| 25 |
|
| 26 |
+
// Transformamos el JSON en una interfaz visual
|
| 27 |
+
let html = "";
|
| 28 |
+
for (const [key, section] of Object.entries(data)) {
|
| 29 |
+
html += `<div class="mb-6 border-l-4 border-indigo-500 pl-4">
|
| 30 |
+
<h3 class="text-lg font-bold capitalize text-indigo-300 mb-2">${key.replace('_', ' ')}</h3>
|
| 31 |
+
<div class="grid gap-2">`;
|
| 32 |
+
|
| 33 |
+
for (const [subKey, val] of Object.entries(section)) {
|
| 34 |
+
html += `<div>
|
| 35 |
+
<span class="text-xs font-bold uppercase text-slate-400">${subKey.replace('_', ' ')}:</span>
|
| 36 |
+
<p class="text-sm text-slate-200">${val}</p>
|
| 37 |
+
</div>`;
|
|
|
|
| 38 |
}
|
| 39 |
+
html += `</div></div>`;
|
|
|
|
|
|
|
| 40 |
}
|
| 41 |
+
content.innerHTML = html;
|
| 42 |
+
} catch (e) {
|
| 43 |
+
content.innerText = "Error procesando el JSON: " + e.message;
|
| 44 |
+
}
|
| 45 |
+
};
|
| 46 |
+
</script>
|