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
原文地址:http://www.cnblogs.com/Answer1215/p/7546309.html