Write in
NodeJS
Observation
9. Create a custom server using http module and explore the other modules of
Node JS like OS,path, event.
AIM: Create a custom server using http module and explore the other modules of Node JS
like OS, path.
DESCRIPTION: Create a custom server using http module and explore the other modules
of Node JS like OS, path.
PROJECT STRUCTURE:
1. [Link]:- It contains http module connection snippet and other modules of Node JS
like OS, path.
1. HTTP Module:
The http module in [Link] allows you to create web servers and handle HTTP
requests and responses.
It is fundamental for building server-side applications that interact with browsers or
other clients over the internet.
Core Concepts:
HTTP: stands for HyperText Transfer Protocol, which is the foundation of data
communication on the web.
Server: A program that listens for incoming HTTP requests, processes them, and
sends back appropriate responses.
Request (req): Contains information about the HTTP request, like the method (GET,
POST, etc.), URL, headers, and query parameters.
Response (res): Represents the server’s response that is sent back to the client.
2. OS Module:
The os module provides information about the operating system where the [Link]
application is running.
Core Concepts:
Platform: The type of operating system (win32 for Windows, linux for Linux, darwin
for macOS).
Architecture: The CPU architecture of the operating system (x64, arm, etc.).
Memory: Methods like [Link]() and [Link]() provide details about total
and free system memory.
CPU: [Link]() provides information about each CPU/core, which can be useful for
understanding the system’s processing power.
3. Path Module:
The path module helps in working with file and directory paths, making file operations
simpler and more consistent across different operating systems.
Core Concepts:
• Absolute and Relative Paths: Paths can be relative to a directory or absolute
• Directory Name ([Link]()): Extracts the directory part from a file path.
• File Name ([Link]()): Extracts the base name (file name with extension)
from a path.
• File Extension ([Link]()): Retrieves the file extension from a file name.