You can always use a bundler in development mode but sometimes you just want a simple HTTP server with basic security and isolated 😉 My favorite tool for that is python
. On macOS and Ubuntu, it's installed by default so no setup is usually required.
This works well because Python ships with an HTTP module in the standard library so it's straightforward to start a server:
$ python -m http.server 2020
Serving HTTP on 0.0.0.0 port 2020 (http://0.0.0.0:2020/) ...
Or if you are still using python2
$ python -m SimpleHTTPServer 8000
Serving HTTP on 0.0.0.0 port 8000 ...
In most cases, the above is enough but in rare cases, you want to bind explicitly to an address:
python -m http.server 2020 --bind 192.168.0.6
Serving HTTP on 192.168.0.6 port 2020 (http://192.168.0.6:2020/) ...
Thanks for reading.
Top comments (0)