Q15.webp
N

Q15.webp

Kizspy | Question: 15
(Choose 3 answers)
Analyze the following Express.js code snippet and determine what it does when accessed via a web browser.
const express = require('express');
const app = express();
app.use((req, res, next) => {
console.log("${req.method} request for '${req.url}");
next();
});
app.get('/', (req, res) => {
res.send('Welcome to the homepage!');
});
app.get('/about', (req, res) => {
res.send('About us');
});
app.use((req, res) => {
});
res.status(404).send('Page not found');
app.listen(3000, () => {
});
console.log('Server running on port 3000');
A. It logs all incoming requests to the console.
B. It returns 'Welcome to the homepage!' for GET requests to the root URL.
C. It returns a 404 error for any undefined routes.
D. It only handles POST requests.

Thông tin

Category
SDN302
Thêm bởi
Ngọc Lan1
Ngày thêm
Lượt xem
2,807
Lượt bình luận
10
Rating
0.00 star(s) 0 đánh giá

Share this media

Back
Bên trên Bottom