1. 程式人生 > >[Node.js] Serve Static Files with Express

[Node.js] Serve Static Files with Express

join node.js nbsp uil pre out styles less class

In this lesson we will find out how to serve static assets (images, css, stylesheets, etc.) with Express. We will go over writing initial boilerplate for a simple Express app, and using Express‘s built-in middleware to serve these assets through a web server on Node.js.

const path = require(‘path‘);
const express 
= require(‘express‘); const app = express(); app.use(‘/images‘, express.static(path.join(__dirname, ‘public/images‘))); app.listen(8080);

[Node.js] Serve Static Files with Express