我想服务index.html和/media子目录作为静态文件。索引文件应该同时在/index.html和/ URLs中提供。
我有
web_server.use("/media", express.static(__dirname + '/media'));
web_server.use("/", express.static(__dirname));
但是第二行显然提供了整个__dirname,包括其中的所有文件(不仅仅是index.html和media),这是我不想要的。
我也试过
web_server.use("/", express.static(__dirname + '/index.html'));
但是访问基本URL /会导致对web_server/index.html/index.html (double index.html组件)的请求,这当然会失败。
什么好主意吗?
顺便说一下,我在Express中绝对找不到关于这个主题的文档(static() +它的params)…令人沮丧。文档链接也很受欢迎。