Archive
web server on localhost
Problem
I wanted to share a 3.3 GB big zip file with my students.
Python
I love Python, so I chose this simple trick: “python3 -m http.server“. It starts a web server and makes the content of the current directory available. I shared the URL with my students (10 people) and they started to download the big file at the same time. And it turned out that Python was not a good choice here since only 1 person could download the file and the others had to wait. This solution is single-threaded :(
Node.js
I hate Node.js but this time it provided the winning solution. Node.js’s async nature was perfect for the job, it could serve several clients. The download rate was not super fast, but at least it worked (and it worked well).
The following tip is from here.
$ sudo npm install http-server -g [sudo] password for jabba: /trash/opt/node-v5.1.0-linux-x64/bin/http-server -> /trash/opt/node-v5.1.0-linux-x64/lib/node_modules/http-server/bin/http-server /trash/opt/node-v5.1.0-linux-x64/bin/hs -> /trash/opt/node-v5.1.0-linux-x64/lib/node_modules/http-server/bin/http-server /trash/opt/node-v5.1.0-linux-x64/lib ...
I couldn’t launch it with “http-server“, but the full path “/trash/opt/node-v5.1.0-linux-x64/lib/node_modules/http-server/bin/http-server” did the trick.
Update (20171123)
Following the instructions at https://nodesource.com/blog/installing-node-js-tutorial-ubuntu/, I upgraded my Node.js to version 6.12.0. Then, installing http-server (with sudo npm install http-server -g), I got a link at “/usr/bin/http-server” that pointed to “/usr/lib/node_modules/http-server/bin/http-server“. Thus, I could start “http-server” without modifying the PATH.