Complete the code to serve static files from the 'public' folder using Express.
app.use([1]('public'));
The express.static middleware serves static files like images, CSS, and JavaScript from a folder.
Complete the code to mount the static middleware at the '/assets' path.
app.use('/assets', [1]('public'));
Mounting express.static at '/assets' serves files under that URL path.
Fix the error in the code to correctly serve static files from the 'static' folder.
app.use(express.static([1]));Using path.join(__dirname, 'static') ensures the correct absolute path is used for static files.
Fill both blanks to create a static middleware that serves files from the 'assets' folder and sets a max age of 1 day.
app.use(express.static([1], { maxAge: [2] }));
The folder path should be absolute using path.join. The maxAge option is in milliseconds; 86400000 ms equals 1 day.
Fill all three blanks to create an Express app that serves static files from 'public', parses JSON bodies, and listens on port 3000.
const express = require('express'); const app = express(); app.use([1]('public')); app.use(express.[2]()); app.listen([3], () => { console.log('Server running'); });
express.static serves static files, express.json() parses JSON request bodies, and app.listen(3000) starts the server on port 3000.