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.

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs