Quick Tip – Starting a Local Web Server with Python

I’ve been doing some web development lately, and came across a great little tip about how to quickly run a local web server. This is especially useful if you’ve ever run into problems with restrictions in executing local javascript files in a browser.

If you have Python installed on your computer, type the following command in your website project directory, to initialize a local web server.

  • python -m SimpleHTTPServer 8888 & (Python v. 2.x) or python -m http.server 8888 & (Python v. 3.x)
  • Then open up a browser and go to the URL http://localhost:8888 and view the website.