Serve static HTML files locally

Shahjada Talukdar
1 min readMar 3, 2019

Sometimes we need to serve static HTML files in localhost. And we really don't want to add any server for a simple HTML file.

Serve static HTML files locally

Generally, we can right click on the HTML file and can say “open in browser” and it will open the file in your local browser(Chrome, Firefox, Edge, Safari) but it’s actually not exactly what we always want. rather we want something like a simple web server to serve the files from a directory.

` http-server` can do exactly that in an easy way.

npm install http-server -g

After installing we can go to our static site directory and can run

http-server

It will serve the directory on localhost 8080 by default.

We can also pass options to that.

Details for the package - https://www.npmjs.com/package/http-server

Cheers! 👋

As I am trying to contribute contents on the Web, you can buy me a coffee for my hours spent on all of these ❤️😊🌸

--

--

Shahjada Talukdar

Senior Software Engineer @eBay. Tech enthusiast, loves JS + few other languages. Keen to learn about Software Engineering/Architecture.