Learning Center
Learning Center
  • HTML
  • CSS
  • JAVASCRIPT
  • Bootstrap
  • React
  • jQuery
  • NodeJs
  • Sql
  • MySql
  • Python
  • OpenVPN Setup
  • Log In
Coding Choice Home About Contact ☰

  1. You are here
  2. Home
  3. nodejs
  4. create_web_server

Sidebar
  • Introduction
  • Getting Started
  • First Application
  • Modules in NodeJs
  • Create Web Server
  • ExpressJs
  • Databases in NodeJs
  • Asynchronous Programming
  • Building REST API
  • WebSockets
  • Deploying Application
  • Share via
    • Share via...
    • Twitter
    • LinkedIn
    • Facebook
    • Pinterest
    • Telegram
    • WhatsApp
    • Yammer
    • Reddit
    • Teams
  • Send via e-Mail
  • Print
  • Permalink

Creating a Simple Web Server

Using the HTTP Module

const http = require("http");
const server = http.createServer((req, res) => {
  res.writeHead(200, { "Content-Type": "text/plain" });
  res.end("Hello, World!");
});
server.listen(3000, () => {
  console.log("Server running at http://localhost:3000");
});

Run the server and visit http://localhost:3000 in your browser.