CNode

求指导,关于express的静态目录

Xx372563572发布于13 年前最后回复13 年前4 回复13021 浏览0 收藏

使用express把静态指向public目录 public/css/xxx.css

浏览器直接访问/css/xxx.css可以输出内容, 怎么才能让浏览器访问/css这个路径输出目录结构啊

查看回复

回复 (4)

B
blwang#1·13 年前

app.use(express.static(__dirname + '/dist'));

X
x372563572#2·13 年前
引用 blwangapp.use(express.static( dirname + '/dist'));

这个是配置静态目录吧。我是想输出静态目录结构,就像apache作为server,访问静态目录下的子目录,会列出该目录下的文件列表那样

B
blwang#3·13 年前

i don't think it has something like that. if you want static listing, you can write an html or ask node to list the file and send back the json.

if you really want that then just use apache or nginx. node or express is not meant to be a static server.

B
bnuhero#4·13 年前

使用directory中间件。

参与回复
登录后即可参与回复。登录