首页 > Web开发 > 详细

[Node.js] Serve Static Files with Express

时间:2017-09-19 01:45:42      阅读:318      评论:0      收藏:0      [点我收藏+]

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!