Tip: Easy way to launch a local server
| Tags: programming
There are many times (especially when doing front-end) where we need to launch a local server to serve static files.
With Python
My favourite one is this Python one-liner directly on the console:
python -m SimpleHttpServer
That will launch a local server at 0.0.0.0:8000
serving the files in the current directory.
The cool thing is that this is using a Python standard module, so as long as you have Python in your system (comes pre-installed in Mac OS X and many Linux distros) you are ready to go.
With Node
You can just install globally the http-server
package from NPM:
npm install -g http-server
And then running http-server
from any directory will statically serve it.