Skip to content

Setting up a local server

yzjing edited this page Oct 25, 2016 · 1 revision

Why

It is useful, and often necessary, to test your HTML file via a local server. This is because browsers often block some Javascript features for security reasons: for example, if you just double-click-open the HTML file, it may not allow the page to access other data files on your computer, which means your data-binding methods won't work. Besides, using a local server ensures a consistent environment when you publish your website online.

How

  1. Open the terminal and cd to the directory where your HTML files are in.

  2. If you're using Python3:

    python -m http.server

    Python2:

    python -m SimpleHTTPServer

  3. On your browser, go to http://localhost:8000/