Last Updated: February 25, 2016
·
1.187K
· deepflame

simple http server for HTML5/JS dev

Using a Mac or Linux
and you are developing HTML or JavaScript stuff?

Guess you have often wondered how to open a simple http server at the current location in the terminal?

Here is a one-liner that requires Python.
Execute in the Shell:

python -m SimpleHTTPServer

That will start a small http server on port 8000.
You may also specify a custom port at the end if you want.

python -m SimpleHTTPServer [port]

As often, I had a Ruby script for that as well. It was simple but this one-liner is really a killer.


PS.:
According to Stackoverflow this is not working in Python 3. Instead you should write:

python -m http.server

Have not tested this however...

2 Responses
Add your response

Cool

over 1 year ago ·

In Python3 version you can use custom port too (see python -m http.server -h for more info).

over 1 year ago ·