Random Scribblings of a Linux Enthusiast

Web Server From Any Directory in Linux

If you want to quickly test a website under development or serve a couple of webpages from a local directory without the hassle of moving/linking the directory to a web server root, the following python command helps:

Run the following command from the intended directory substituting [port] with the required value. It defaults to 8000 if nothing is specified.

For Python2,

python -m SimpleHTTPServer [port]

For Python3,

python -m http.server [port]