Recall & Review
beginner
What is Express in Node.js?
Express is a simple and flexible web framework for Node.js that helps you build web servers and APIs easily.
Click to reveal answer
beginner
Which method creates an Express application?
The method
express() creates an Express application instance.Click to reveal answer
beginner
How do you make an Express server listen on port 3000?
Use
app.listen(3000, () => { console.log('Server running on port 3000') }) to start the server on port 3000.Click to reveal answer
beginner
What does
app.get('/', (req, res) => { ... }) do?It defines a route handler for GET requests to the root URL '/' and sends a response back to the client.
Click to reveal answer
beginner
Why do we use
res.send() in Express?res.send() sends a response back to the client, like text or HTML, to show in the browser.Click to reveal answer
Which line creates a new Express app?
✗ Incorrect
The correct way to create an Express app is by calling express() as a function.
How do you define a route for GET requests to '/'?
✗ Incorrect
app.get() defines a handler for GET requests to the specified path.
What does app.listen(3000) do?
✗ Incorrect
app.listen(3000) starts the server and listens for requests on port 3000.
Which object represents the incoming request in a route handler?
✗ Incorrect
The 'req' object holds information about the incoming request.
Which method sends a response back to the client?
✗ Incorrect
res.send() is used to send a response to the client.
Explain how to create a basic Express server that responds with 'Hello World' on the root URL.
Think about the steps from importing Express to starting the server.
You got /5 concepts.
Describe the roles of the 'req' and 'res' objects in an Express route handler.
One is for input, the other for output.
You got /3 concepts.