Create an HTTP server using 1 command

Create an HTTP server using 1 command

Today we will learn how to create an HTTP server for the local development of sites, it is a very cool tool to do tests and visualize how the website will look when it is hosted.

Pre-requisites:
Node.js is installed on your machine.

Create a folder for your project and open it in your favorite editor. I will use Visual Studio Code.

Create an HTML file(index.html) with the following code:

<!DOCTYPE html>
<html lang="en">
<body>
    <h1>Hello World</h1>
</body>
</html>

Open the terminal and type the following command:

npx http-server

This command will create a local server on port 8080. Open your browser and type the following URL:

http://localhost:8080

Done! You have created your first local server.

Create an HTTP server using 1 command | DevsMitra


If you enjoyed reading this short blog, you may also want to check out my javascript short playlist on YouTube.
Must Read If you haven't

React best practices and patterns to reduce code - Part 1

React best practices and patterns to reduce code - Part 2

React.js state management using signals

useAsync hook with cache

More content at Hashnode.
Catch me on: Youtube, Github, Twitter, LinkedIn, Medium, Dev.to, Blogspot, Stackblitz