1. Home
  2. Node
  3. Http

Node comes with a full support for setting up a HTTP server. With a few lines of code you can build a simple web server.

// Load HTTP module
const http = require('http');

// Create an instance of a server
const server = http.createServer((req, res) => {
    // Set a route
    if (req.url === '/') {
        // Send back the response back
        res.write("Node HTTP module in action");

// Start the server on a port 3000
console.log('Server listening on port 3000');
Full Node cheatsheet