Node.js 快速文件服务器(HTTP 上的静态文件)

问题描述:

是否有 Node.js 即用型工具(与 npm 一起安装),这将帮助我通过 HTTP 将文件夹内容公开为文件服务器.

Is there Node.js ready-to-use tool (installed with npm), that would help me expose folder content as file server over HTTP.

例如,如果我有

D:Folderfile.zip
D:Folderfile2.html
D:Folderfolderfile-in-folder.jpg

然后从 D:Folder node node-file-server.js 开始我可以通过

Then starting in D:Folder node node-file-server.js I could access file via

http://hostname/file.zip
http://hostname/file2.html
http://hostname/folder/file-in-folder.jpg

为什么我的节点静态文件服务器丢弃请求?参考一些神秘的

标准 node.js 静态文件服务器

standard node.js static file server

如果没有这样的工具,我应该使用什么框架?

If there's no such tool, what framework should I use?

相关:NodeJS 中的基本静态文件服务器

一个好的即用型工具"选项可能是 http-server:

A good "ready-to-use tool" option could be http-server:

npm install http-server -g

使用:

cd D:Folder
http-server

或者,像这样:

http-server D:Folder

检查一下:https://github.com/nodeapps/http-server