Serving static files in Express: Express allows you to serve static files, such as images, CSS files, and JavaScript files. You can use the express.static middleware to serve these files from a directory. Here's an example of how to serve static files in Express:
javascript
const express = require('express');
const app = express();
app.use(express.static('public'));
app.listen(3000, () => {
console.log('Server listening on port 3000');
});
In this example, the public directory contains the static files that will be served by Express.
No comments:
Post a Comment