I just discovered this really simple hack which is both a time and life saver if you want to quickly test simple websites on your machine. From any folder (a GIT folder for example where your code is), you simply need to run this simple Python command:
python -m SimpleHTTPServer 8000
UPDATE! Since Python 3, it has now changed to this:
python3 -m http.server
As you may have guessed, this will start a web server on port 8000. So from your browser, now all you need to do is go to http://localhost:8000 and, magic, you can now see the website you’re working on. To make it faster in the future, make it an executable file. Here’s a quick and easy way to do that, again, from that folder you’re working in:
echo "python -m SimpleHTTPServer 8000" > run.sh
chmod a+x run.sh
Or, if you are using Python 3:
echo "python3 -m http.server" > run.sh
chmod a+x run.sh
Then to run it next time without having to remember the whole thing, simply type:
./run.sh
That’s it! Enjoy. Below is the source of where I found this awesome trick:
https://lifehacker.com/start-a-simple-web-server-from-any-directory-on-your-ma-496425450