Which code snippet correctly creates a Node.js HTTP server that responds with JSON {"message":"success"} and sets the appropriate headers?
Aconst http = require('http');
const server = http.createServer((req, res) => {
res.writeHead(200, {'Content-Type': 'application/json'});
res.end(JSON.stringify({message: 'success'}));
});
server.listen(3000);
Bconst http = require('http');
const server = http.createServer((req, res) => {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('{"message":"success"}');
});
server.listen(3000);
Cconst http = require('http');
const server = http.createServer((req, res) => {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('<p>{"message":"success"}</p>');
});
server.listen(3000);
Dconst http = require('http');
const server = http.createServer((req, res) => {
res.end(JSON.stringify({message: 'success'}));
});
server.listen(3000);