Recall & Review
beginner
What is the purpose of serving static files from multiple directories in Express?
It allows your web server to deliver files like images, CSS, and JavaScript from different folders, making it easier to organize and manage resources.
Click to reveal answer
beginner
How do you serve static files from multiple directories in Express?
You use multiple calls to express.static middleware, each pointing to a different folder, and add them to your app with app.use().
Click to reveal answer
intermediate
What happens if two static directories contain files with the same name?
Express serves the file from the first directory that matches the request path, ignoring the others for that file name.
Click to reveal answer
beginner
Show a simple example code snippet to serve static files from 'public' and 'assets' folders in Express.
app.use(express.static('public'));
app.use(express.static('assets'));
Click to reveal answer
beginner
Why is it important to serve static files efficiently in a web app?
Serving static files efficiently improves page load speed and user experience by quickly delivering images, styles, and scripts without extra processing.
Click to reveal answer
Which Express method is used to serve static files from a directory?
✗ Incorrect
express.static() is the middleware function used to serve static files.
How do you add multiple static directories in Express?
✗ Incorrect
You add multiple static directories by calling app.use() multiple times with express.static() for each folder.
If two static directories have a file named 'logo.png', which one will Express serve?
✗ Incorrect
Express serves the first matching file it finds based on the order of app.use() calls.
What is a benefit of organizing static files into multiple directories?
✗ Incorrect
Using multiple directories helps keep files organized and easier to manage.
Which of these is NOT a static file typically served by Express?
✗ Incorrect
Database queries are dynamic operations, not static files.
Explain how to serve static files from two different folders in Express and what happens if files have the same name.
Think about middleware order and file lookup.
You got /3 concepts.
Describe why serving static files efficiently matters in a web application and how multiple directories can help.
Consider user experience and code organization.
You got /4 concepts.