const express = require('express'); const fs = require('fs'); const path = require('path'); const app = express(); const PORT = 3000; const DIRECTORY = path.join(__dirname, 'tables'); // Change to your directory app.get('/', (req, res) => { fs.readdir(DIRECTORY, (err, files) => { if (err) return res.status(500).send('Error reading directory'); let html = '
${escapeHtml(data)}Back`);
});
});
function escapeHtml(text) {
return text.replace(/[&<>"']/g, function(m) {
return ({
'&': '&',
'<': '<',
'>': '>',
'"': '"',
"'": '''
})[m];
});
}
app.listen(PORT, () => {
console.log(`Server running at http://localhost:${PORT}`);
});