Since quite some time I make sure to compile my system’s BusyBox with the included httpd to have a minimal web server available when I need it. A quick
$ busybox httpd -p 8080
is enough to offer the current directory via HTTP on port 8080. This post describes an alternative which has the advantage of being available on almost every Linux installation: Python comes with a built-in web server. Just go into the directory you want to use as the server’s root and run:
$ python -m SimpleHTTPServer 8080
If you don’t specify a port number, the server will use port 8000 (and fail if it can’t bind it). Directory listings are supported. In Python 3, the module is called
$ python3 -m http.server 8113
Serving HTTP on 0.0.0.0 port 8113 ...
localhost - - [11/Jun/2010 19:53:26] "GET / HTTP/1.1" 200 -
localhost - - [11/Jun/2010 19:53:27] code 404, message File not found
localhost - - [11/Jun/2010 19:53:27] "GET /favicon.ico HTTP/1.1" 404 -
[some more transfers...]
Keyboard interrupt received, exiting.
Quite useful when you just want to get some files from one computer to another, and the recipient needs only a browser (or any other HTTP client). However, BusyBox’s httpd is more configurable (just check
busybox httpd --help), so I am going to keep it around.