Option A: Zero-Dependency Node.js Auto-Save Server (server.js)
Save as server.js alongside index.html and wishlist.csv, then run node server.js in VS Code's terminal:
const http = require('http'), fs = require('fs'), path = require('path');
const PORT = 8000, DIR = __dirname;
const MIME = { '.html':'text/html', '.csv':'text/csv', '.js':'application/javascript', '.css':'text/css', '.json':'application/json' };
http.createServer((req, res) => {
if (req.method === 'POST' && req.url === '/api/save-csv') {
let body = '';
req.on('data', c => body += c);
req.on('end', () => {
fs.writeFileSync(path.join(DIR, 'wishlist.csv'), body, 'utf8');
res.writeHead(200, {'Content-Type':'application/json'});
res.end('{"ok":true}');
});
return;
}
const clean = req.url.split('?')[0] === '/' ? '/index.html' : req.url.split('?')[0];
const file = path.join(DIR, clean);
if (fs.existsSync(file) && fs.statSync(file).isFile()) {
res.writeHead(200, {'Content-Type': MIME[path.extname(file)] || 'application/octet-stream'});
fs.createReadStream(file).pipe(res);
} else { res.writeHead(404); res.end('Not found'); }
}).listen(PORT, () => console.log('Wishlist running at http://localhost:' + PORT));