FLUJOS/POCS/BACK_BACK/FLUJOS_APP_PRUEBAS.js
CAPITANSITO 25953376cd Reorganize POCs and demos under POCS/ folder
- Move BACK_BACK/ → POCS/BACK_BACK/ (image pipeline scripts)
- Move VISUALIZACION/ → POCS/VISUALIZACION/ (demos + static assets)
- No path changes needed: ../VISUALIZACION/public still resolves correctly
  from POCS/BACK_BACK/FLUJOS_APP_PRUEBAS.js
- Add FLUJOS_DATOS/DOCS/extraer_info_bbdd.txt (DB state snapshot + commands)

FLUJOS/ and FLUJOS_DATOS/ untouched (production).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 01:22:27 +02:00

97 lines
3.4 KiB
JavaScript

// FLUJOS_APP_PRUEBAS.js
// Servidor ligero para probar los demos de visualización SIN necesitar MongoDB.
// No modifica ni interfiere con FLUJOS_APP.js.
// Arrancarlo: node FLUJOS_APP_PRUEBAS.js
// URL: http://localhost:3001/demos/demo_text_nodes.html
const express = require('express');
const path = require('path');
const helmet = require('helmet');
const app = express();
const PORT = 3001;
// CSP ampliada para permitir esm.sh (demos usan ES modules desde CDN)
app.use(
helmet.contentSecurityPolicy({
directives: {
defaultSrc: ["'self'"],
scriptSrc: [
"'self'",
"'unsafe-inline'",
"'unsafe-eval'",
'https://unpkg.com',
'https://cdnjs.cloudflare.com',
'https://fonts.googleapis.com',
'https://esm.sh',
],
scriptSrcElem: [
"'self'",
"'unsafe-inline'",
'https://unpkg.com',
'https://cdnjs.cloudflare.com',
'https://esm.sh',
],
styleSrc: ["'self'", "'unsafe-inline'", 'https://fonts.googleapis.com'],
fontSrc: ["'self'", 'https://fonts.gstatic.com', 'https://fonts.googleapis.com'],
imgSrc: ["'self'", 'data:', 'blob:'],
connectSrc: ["'self'", 'https://esm.sh', 'ws://localhost:3001'],
workerSrc: ["'self'", 'blob:'],
scriptSrcAttr: ["'unsafe-inline'"],
},
})
);
// Ruta raíz → index de demos (debe ir ANTES del middleware estático)
app.get('/', (req, res) => {
res.send(`
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>FLUJOS — Demos</title>
<style>
body { background:#000; color:#39ff14; font-family:'Courier New',monospace; padding:40px; }
h1 { font-size:1.4em; letter-spacing:4px; margin-bottom:8px; text-shadow:0 0 10px #39ff14; }
p { font-size:0.75em; color:#555; margin-bottom:30px; }
ul { list-style:none; padding:0; }
li { margin-bottom:12px; }
a { color:#39ff14; text-decoration:none; font-size:0.9em; letter-spacing:1px;
border:1px solid #222; padding:8px 16px; display:inline-block;
transition:border-color 0.2s, box-shadow 0.2s; }
a:hover { border-color:#39ff14; box-shadow:0 0 8px #39ff14; }
.tag { font-size:0.65em; color:#555; margin-left:10px; }
</style>
</head>
<body>
<h1>FLUJOS · DEMOS</h1>
<p>Servidor de pruebas — sin MongoDB · puerto 3001</p>
<ul>
<li>
<a href="/demos/demo_text_nodes.html">demo_text_nodes</a>
<span class="tag">three-spritetext · texto como nodo</span>
</li>
<li>
<a href="/demos/demo_img_nodes.html">demo_img_nodes</a>
<span class="tag">THREE.Sprite · imágenes como nodo</span>
</li>
<li>
<a href="/demos/demo_mixed_nodes.html">demo_mixed_nodes</a>
<span class="tag">CSS2DRenderer · cards HTML en 3D</span>
</li>
</ul>
</body>
</html>
`);
});
// Archivos estáticos (después de la ruta raíz)
app.use(express.static(path.join(__dirname, '../VISUALIZACION/public')));
app.listen(PORT, '0.0.0.0', () => {
console.log(`\n FLUJOS PRUEBAS corriendo en http://localhost:${PORT}`);
console.log(` Demos disponibles:`);
console.log(` http://localhost:${PORT}/demos/demo_text_nodes.html`);
console.log(` http://localhost:${PORT}/demos/demo_img_nodes.html`);
console.log(` http://localhost:${PORT}/demos/demo_mixed_nodes.html\n`);
});