Sometimes, we need to share some files quickly on the network for our colleagues or family.
Of course, we can set up Nginx, or something else. But to this quickly and easily, and mostly, only temporarily, we can do this using many different languages quite easily.
Ruby has this functionality built-in as part of it’s core features! The following command runs a WEBrick server of the current directory at port
ruby -run -e httpd
For Node, we need to install a package called http-server which we need to install globally first.
npm install -g http-server
And then we can run the command in the directory we want to share. This runs on
http://localhost:8080, the same as Ruby above
PHP also has this capability built-in. However, you need to specify the URL to which you want to serve the directory.
php -S localhost:8080
In Python, the module
SimplHTTPServer achieves the same purpose
python -m SimpleHTTPServer
This serves the current directory on http://localhost:8000
Following are the links to the blog articles by David Walsh.