An easy way to start a HTTP server serving static content/files

I was looking for a oneliner to start a HTTP server and serve static content from a directory. Python's SimpleHTTPServer is the perfect match for the job. Smile Python is already installed by most linux distributions by default and it's easily available for a lot of other platforms as well. Starting your own little HTTP server was never easier than this:
python2 -m SimpleHTTPServer 8080
And to access it, open the http://localhost:8080/ URL.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: An easy way to start a HTTP server serving static content

In Python 3.4+ the same functionality is in the http.server module and it got extra parameters. Now you can specify the address to bind to and not just the port. See: https://docs.python.org/3/library/http.server.html
python3 -m http.server 8080 --bind 127.0.0.1