Paul Verest Paul Verest - 5 months ago 25
Node.js Question

Node.js quick file server (static files over HTTP)

Is there Node.js ready-to-use tool (installed with

npm
), that would help me expose folder content as file server over HTTP.

Example, if I have

D:\Folder\file.zip
D:\Folder\file2.html
D:\Folder\folder\file-in-folder.jpg


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


Why is my node static file server dropping requests?
reference some mystical


standard node.js static file server


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

Related:
Basic static file server in NodeJS

Answer

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

npm install http-server -g

To use it:

cd D:\Folder
http-server

Or, like this:

http-server D:\Folder

Check it out: https://github.com/nodeapps/http-server