跳到主要内容
CNode

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

社区
Xx372563572发布于 13 年前最后回复 13 年前
4130380

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

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

查看回复

回复 (4)

B
bnuhero#413 年前

使用directory中间件。

B
blwang#313 年前

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.

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

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

B
blwang#113 年前

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

参与回复

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