Install http-server globally
Installing http-server is simple with the following command:
The “-g” switch installs this library locally. I tried it without that switch, but it did not work. However, the advantage of installing it globally is that it will work in any new folder you create on your computer.
Create Web Files to Render
Start Web Server
Test it Out
Now you can open a browser and navigate to a page, as shown below:
Notice that you don’t need to type the “.html” or “.htm” extension. The server is smart enough to know the page you are looking for.
It is also smart enough to assume a page with a name like “index.html”, “home.htm”, or “default.htm” is a a default page and render this page when none is specified, as shown below:
This is a very simple way to quickly install, configure, and start a lightweight web server on your local PC for testing or creating static pages.