How can you serve multiple static directories using Express.js?
- app.static('directory1'); app.static('directory2');
- app.use(express.static('directory1')); app.use(express.static('directory2'));
- app.static('directory1, directory2');
- app.use(express.static(['directory1', 'directory2']));
To serve multiple static directories in Express.js, you should use the express.static middleware function multiple times with different directory paths. This allows you to specify and configure each static directory separately. The other options are not valid syntax for serving multiple static directories.
Loading...
Related Quiz
- What is the purpose of the res.send() method in Express?
- In JavaScript, the condition in an if statement is converted to a ________ value.
- Which npm script is automatically run when the npm publish command is executed?
- When designing a schema for a SQL database in Node.js, the ______ key is used to establish a relationship between two tables.
- You are tasked with optimizing a large-scale application. How would identifying and managing closures help in optimizing the application's memory usage and performance?