Serving Static Files from Multiple Directories in Express
📖 Scenario: You are building a simple web server using Express.js. You want to serve static files like images, CSS, and JavaScript from two different folders: public and assets. This way, your website can load files from both places seamlessly.
🎯 Goal: Build an Express server that serves static files from two directories: public and assets. When a user visits your site, files from both folders should be accessible.
📋 What You'll Learn
Create an Express app instance
Serve static files from the
public directoryServe static files from the
assets directoryListen on port 3000
💡 Why This Matters
🌍 Real World
Web servers often need to serve static files like images, stylesheets, and scripts from multiple folders. This project shows how to do that with Express.
💼 Career
Knowing how to serve static assets from multiple directories is a common task for backend developers working with Node.js and Express.
Progress0 / 4 steps