Last Updated: February 25, 2016
·
1.418K
· 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 ·

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside