Serving Static Files in Express

In order to serve static files using express, you must first create a public folder which stores the data you want to serve. Once you’ve stored your files within the public folder, you will make use of the built in express.static middleware for express.

EXPRESS.STATIC()

The express.static function allows you to serve files in your public directory to the client.

//app is using middleware to serve public folder
app.use(express.static('public'));

When you call express.static multiple times, you are able to use multiple static directories.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.