DEV Community

Cover image for Create an HTTP server using 1 command
Rahul Sharma
Rahul Sharma

Posted on

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.

Create an HTTP server using 1 command

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

Create a folder for your project and open it in your favorite editor.

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

<!DOCTYPE html>
<html lang="en">
<body>
    <h1>Hello World</h1>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

Open the terminal and type the following command:

npx http-server
Enter fullscreen mode Exit fullscreen mode

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

http://localhost:8080
Enter fullscreen mode Exit fullscreen mode

Done! You have created your first local server.

Create an HTTP server using 1 command


Must Read If you haven't
3 steps to create custom state management library with React and Context API
How to cancel Javascript API request with AbortController
Getting started with SolidJs – A Beginner's Guide

More content at Dev.to.
Catch me on YouTube, Github, Twitter, LinkedIn, Medium, Stackblitz, Hashnode, HackerNoon, and Blogspot.

Top comments (0)