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 ❤️😊🌸

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Shahjada Talukdar
Shahjada Talukdar

Written by Shahjada Talukdar

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

Responses (1)

Write a response

Thank you ShahJada. Your article has helped me much.
Best,
Duncan H.

1