node-static is a simple, rfc 2616 compliant file streaming module for Node.js which can be used for making any of your directory a static file server. You can use this as a command-line tool to make a directory to a server or as a library for creating custom file server.

node-static can be easily installed using npm (we'll make it global for using the command-line tool)

$ npm install node-static

To start the server, move the directory from where you want to serve the files and hit the following command.

$ static

It'll start the server at port 8080 with the current directory as root. Read the node-static documentation to learn more about this library.

blog comments powered by Disqus