How to open HTML file on localhost

JS Developers
1 min readJan 27, 2021

Here we’ll discuss how we can start the local server with an HTML file and also how to run a javascript file in the browser. Because may time we’re struggling to run javascript file in browser but it requires HTML file with the path of js file in the script tag to open it in the browser.

Photo by Nathan da Silva on Unsplash

What is localhost

Localhost is an URL on the browser that points to itself means your system. The browser doesn't require internet for the localhost to work since it only checks on itself.

To access localhost, you write localhost or 127.0.0.1 in the browser.

Steps to Run HTML file on localhost

There are many ways we can achieve this. following is one of them in which we’ll python.

For this, you must have installed Python in your system. you can check it with the following command in Linux or mac

python -v 

if python already installed then followed the following steps:

  1. Open the terminal and navigate to the folder contains the file you want to run.
  2. Run the following command
python -m SimpleHTTPServer

3. open the browser and enter the URL http://127.0.0.1:8000/

--

--