Complete the code to create an Express app instance.
const express = require('express'); const app = express(); app.[1]('/', (req, res) => { res.send('Hello World'); });
The get method defines a route handler for GET requests on the root path.
Complete the code to start the Express server on port 3000.
app.[1](3000, () => { console.log('Server running on port 3000'); });
The listen method starts the server and listens on the specified port.
Fix the error in the code to correctly create an HTTP server using Express.
const http = require('http'); const express = require('express'); const app = express(); const server = http.createServer([1]); server.listen(3000);
The http.createServer method expects a request listener function, which Express app provides.
Fill both blanks to create an Express app and start the HTTP server on port 4000.
const http = require('http'); const express = require('express'); const app = [1](); const server = http.createServer([2]); server.listen(4000);
First, call express() to create the app. Then pass app to createServer.
Fill all three blanks to define a GET route and start the Express server on port 5000.
const express = require('express'); const app = express(); app.[1]('/hello', (req, res) => { res.[2]('Hello Express'); }); app.[3](5000, () => { console.log('Server listening on port 5000'); });
Use get to define the route, send to respond, and listen to start the server.
