Which method in Express.js is used to serve static files?
- app.static()
- app.useStatic()
- app.serveStatic()
- app.use()
In Express.js, the app.use(express.static()) method is used to serve static files. This method allows you to specify a directory from which Express should serve static assets like images, CSS, and JavaScript. The other options are not valid methods for serving static files in Express.
Loading...
Related Quiz
- How can you install ESLint in your Node.js project?
- What is the significance of the process.nextTick() method in Node.js?
- You are maintaining a server that has strict security requirements. You need to allow cross-origin requests but with stringent restrictions. How can you implement CORS to fulfill these requirements while maintaining security?
- When designing systems with Non-Blocking I/O, careful consideration must be given to avoid ________, where multiple asynchronous operations are competing for resources.
- You are designing a real-time data processing system where data needs to be transformed before being sent to another service. How would you implement streams in Node.js to ensure smooth data transformation and transmission?