Search code examples
node.jshttpfileserver

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


Solution

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

    npx http-server -o /path/to/static/content
    

    Being a NPM package, can also installed

    npm install http-server -g
    http-server -o /path/to/static/content