A. express.static is missing the folder path argument
B. app.listen should come before app.use
C. express.static should be called without parentheses
D. The folder name should be 'public' not 'static'
Solution
Step 1: Check express.static usage
express.static is a function that requires the folder path as an argument.
Step 2: Identify missing argument
The code uses express.static without parentheses and folder name, so it won't work.
Final Answer:
express.static is missing the folder path argument -> Option A
Quick Check:
express.static needs folder path argument [OK]
Hint: express.static must be called with folder path [OK]
Common Mistakes:
Forgetting to call express.static as a function
Thinking app.listen order matters here
Assuming folder name must be 'public'
5. You want to serve static files from two folders: public and uploads. Which code correctly serves both folders so files from either can be accessed by URL?
hard
A. app.use(express.static('public'));
app.use(express.static('uploads'));
B. app.use(express.static(['public', 'uploads']));
Express allows multiple static folders by calling app.use(express.static()) multiple times.
Step 2: Evaluate options
app.use(express.static('public'));
app.use(express.static('uploads')); correctly calls express.static twice for each folder. app.use(express.static(['public', 'uploads'])); is invalid syntax. app.use(express.static('public/uploads')); tries to serve a combined folder that likely doesn't exist. app.static('public');
app.static('uploads'); uses a wrong method.
Final Answer:
app.use(express.static('public'));
app.use(express.static('uploads')); -> Option A