码迷,mamicode.com
首页 > Web开发 > 详细

[Node.js] Serve Static Files with Express

时间:2017-09-19 03:58:58      阅读:261      评论:0      收藏:0      [点我收藏+]

标签:assets   tin   image   pat   sso   ddl   his   exp   node   

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

标签:assets   tin   image   pat   sso   ddl   his   exp   node   

原文地址:http://www.cnblogs.com/Answer1215/p/7546309.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!