One-line Static HTTP Server
From Leo's Notes
Last edited on 20 August 2020, at 19:56.
Here is a collection of simple static web servers can be started with one line.
Python
# If Python version returned above is 3.X
python3 -m http.server 8000
# If Python version returned above is 2.X
python -m SimpleHTTPServer 8000
PHP
For PHP versions >= 5.4
$ php -S 127.0.0.1:8000
BusyBox's httpd
$ busybox httpd -f -p 8080
The nice thing with BusyBox is that you can also set up basic authentication, though it requires a separate configuration file and isn't technically a one-liner.
$ httpd -m my-secret-password
$1$SALT$HASH
$ echo '/:username:$1$SALT$HASH' >> httpd.conf
$ httpd -v -f -p 8080 -r "Login required" -c httpd.conf
See Also
- More found on this gist: https://gist.github.com/willurd/5720255