jamalinu commited on
Commit
ffcdfad
·
verified ·
1 Parent(s): bffd320

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +41 -50
index.html CHANGED
@@ -1,55 +1,46 @@
1
- <!DOCTYPE html>
2
- <html lang="es">
3
- <head>
4
- <meta charset="UTF-8">
5
- <script src="https://cdn.tailwindcss.com"></script>
6
- <title>PragmaLens AI Audit</title>
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
- <div id="results" class="mt-8 hidden bg-slate-800 p-6 rounded-xl border border-indigo-500/30">
19
- <h2 class="text-xl font-bold mb-4 text-indigo-300">Resultados del Análisis</h2>
20
- <div id="content" class="text-sm space-y-4"></div>
21
- </div>
22
- </div>
23
 
24
- <script>
25
- document.getElementById('analyzeBtn').onclick = async () => {
26
- const resDiv = document.getElementById('results');
27
- const content = document.getElementById('content');
28
- const file = document.getElementById('pdfInput').files[0];
29
- const text = document.getElementById('textInput').value;
30
-
31
- resDiv.classList.remove('hidden');
32
- content.innerText = "Procesando análisis lingüístico...";
 
 
 
 
 
33
 
34
- try {
35
- let data;
36
- if (file) {
37
- const fd = new FormData();
38
- fd.append('file', file);
39
- const res = await fetch('/analyze_pdf', {method: 'POST', body: fd});
40
- data = await res.json();
41
- } else {
42
- const res = await fetch('/analyze', {
43
- method: 'POST', headers: {'Content-Type': 'application/json'},
44
- body: JSON.stringify({text})
45
- });
46
- data = await res.json();
47
  }
48
- content.innerHTML = `<pre class="whitespace-pre-wrap">${JSON.stringify(data, null, 2)}</pre>`;
49
- } catch (e) {
50
- content.innerText = "Error: " + e.message;
51
  }
52
- };
53
- </script>
54
- </body>
55
- </html>
 
 
 
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>