Complete the code to import the HTTP module.
const http = require('[1]');
The HTTP module is imported using require('http') to create a server.
Complete the code to create an HTTP server.
const server = http.[1]((req, res) => { res.end('Hello World'); });
The createServer method creates a new HTTP server that handles requests.
Fix the error in the code to start the server on port 3000.
server.[1](3000, () => { console.log('Server running on port 3000'); });
The listen method starts the server and listens on the specified port.
Fill both blanks to send a plain text response with status 200.
res.statusCode = [1]; res.setHeader('Content-Type', [2]); res.end('Hello');
Status code 200 means OK, and 'text/plain' sets the response type to plain text.
Fill all three blanks to create a server that responds with JSON and listens on port 8080.
const server = http.[1]((req, res) => { res.statusCode = [2]; res.setHeader('Content-Type', [3]); res.end(JSON.stringify({ message: 'Hi' })); }); server.listen(8080);
The server is created with createServer, status code 200 means OK, and content type 'application/json' tells the browser to expect JSON data.
