Prabros. blue logo

Prabros.

Landscape of the Web

A Concise Node.js Server

Here is a concise program that spawns a barebones Node.js server. It says “Hello there!” on running.

const http = require('http');
const port = 3000;

const app = http.createServer((req,res) => {
    res.writeHead(200);
    res.end("Hello there!");
});

app.listen(port);

We have created a simple inspectable artefact here. Try copy pasting it on a text file named server.js and running it with: node server.js makes a good ground to talk about the various elements that goes into the creation of a server program. This fundamentals up approach enables communication about ideas and concepts in server building by making them tractable.