if (url === '/message' && method === 'POST') {
const body = [];
req.on('data', chunk => {
body.push(chunk);
});
req.on('end', () => {
const parsedBody = Buffer.concat(body).toString();
let message = parsedBody.split('=')[1];
console.log(message);
fs.writeFileSync('messages.txt', message);
res.statusCode = 302;
res.setHeader('location', '/');
return res.end();
});
}