Tech TutorBangla Web Documentation
Portfolio
HomeHTMLCSSTailwind CSSJavaScriptTypeScriptReactNext.jsNode.jsExpressSocket.IOExpoWordPressPostgreSQLPrismaPostgresNestJSMongoDBDockerTanStackTanStack TableRTK QueryGitGitHub
  • Node.js Documentation20টি অধ্যায়
প্রযুক্তি নির্বাচন
HomeHTMLCSSTailwind CSSJavaScriptTypeScriptReactNext.jsNode.jsExpressSocket.IOExpoWordPressPostgreSQLPrismaPostgresNestJSMongoDBDockerTanStackTanStack TableRTK QueryGitGitHub
  • Introduction
  • Installation
  • Modules
  • NPM
  • File System
  • Events
  • Streams
  • HTTP
  • Async Programming
  • Environment
  • Debugging
  • Express.js
  • API Development
  • Authentication
  • Database
  • Production
  • Advanced Node.js
  • Best Practices
  • Projects
  • Interview
  1. Docs
  2. Node.js
  3. Node.js HTTP Module
Node.jsIntermediate

Node.js HTTP Module

HTTP server, client, request/response, routing — Node.js-এ web server তৈরির বাংলা গাইড।

10টি অংশবাংলা ভাষায়

Node.js-এর built-in http module দিয়ে আপনি নিজেই HTTP server ও client তৈরি করতে পারবেন। Express.js এই module-এর উপরই তৈরি।

HTTP Server তৈরি

server.jsjavascript
javascript
const http = require("node:http");

const server = http.createServer((req, res) => {
  console.log(req.method, req.url);

  // different routes
  if (req.url === "/") {
    res.writeHead(200, { "Content-Type": "text/html" });
    res.end("<h1>হোম পেজ</h1>");
  } else if (req.url === "/api/users") {
    res.writeHead(200, { "Content-Type": "application/json" });
    res.end(JSON.stringify([
      { id: 1, name: "রহিম" },
      { id: 2, name: "করিম" },
    ]));
  } else {
    res.writeHead(404, { "Content-Type": "text/plain" });
    res.end("পাওয়া যায়নি");
  }
});

server.listen(3000, () => {
  console.log("Server http://localhost:3000-এ চালু");
});

Request Object (req)

Propertyকাজ
req.methodHTTP method (GET, POST, PUT, DELETE)
req.urlRequest URL
req.headersসব headers
req.paramsURL parameters
req.queryQuery string parameters

Response Object (res)

Methodকাজ
res.writeHead(status, headers)Status code ও headers সেট
res.write(data)Response body লেখা
res.end(data)Response শেষ করা
res.setHeader(name, value)Header সেট করা

POST Request Handle করা

server.jsjavascript
javascript
const http = require("node:http");

const server = http.createServer((req, res) => {
  if (req.method === "POST" && req.url === "/api/users") {
    let body = "";

    req.on("data", (chunk) => {
      body += chunk.toString();
    });

    req.on("end", () => {
      const user = JSON.parse(body);
      res.writeHead(201, { "Content-Type": "application/json" });
      res.end(JSON.stringify({
        message: "User তৈরি হয়েছে",
        user: { id: Date.now(), ...user },
      }));
    });
  }
});

server.listen(3000);
মনে রাখুন

Production-এ সোজাসুজি http module ব্যবহার না করে Express.js ব্যবহার করুন — এতে routing, middleware, error handling সহজ হয়।

শেষ প্যারায় নিজে practice করুন — কোড কপি করে নিজের এডিটরে চালিয়ে দেখুন।
আগেরNode.js StreamsপরেরAsync Programming — Callback, Promise, async/await
এই পেজে
Tech Tutor

বাংলায় ওয়েব ডেভেলপমেন্ট ডকুমেন্টেশন শিখুন — ধাপে ধাপে।

Homeসব ডকুমেন্টেশনQuick Startআমার নোটস

© 2026 Tech Tutor. বাংলায় শিখুন, বাংলায় গড়ুন।

mdanamolhasan1998@gmail.com