Serving Static Assets In Express

using the express.static middleware in an Express app.

Serve static content for the app from the “public” directory in the application directory:

Serving Static Assets In Express

index.js
// GET /style.css etc app.use(express.static(path.join(__dirname, 'public')))

在工程目录下新建一个public文件夹,该文件夹下放static contents, like app.css, app.js, etc.

app.css

body{ background-color: pink; }

在对应的ejs文件下添加依赖: 

<link rel="stylesheet" href="/app.css">

Serving Static Assets In Express

上一篇:HDU(搜索专题) 1000 N皇后问题(深度优先搜索DFS)解题报告


下一篇:腾讯 angel 3.0:高效处理模型