Skip to content

ritvikvr/NodeJS---HTTP-FS-URL-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 

Repository files navigation

NodeJS---HTTP-FS-URL-module

🌐 Ritvik's Pure Node.js HTTP Server A minimal, zero-dependency HTTP server built from scratch using only Node.js core modules (http, fs, url, path). This project serves as a foundational exercise to understand raw HTTP request handling and file system operations in Node.js.

✨ Features Pure Node.js: Built without any frameworks (like Express), relying solely on core Node.js modules.

Static File Serving: Efficiently serves index.html, about.html, and styles.css.

Intelligent Routing: Uses the built-in url module to parse incoming requests and route them based on the pathname.

Robust Error Handling: If an HTML file fails to load, the server logs the error to an error.log file and sends a basic HTML fallback message to the client.

404 Catch-all: Returns a standard "404 - Page Not Found" for unknown routes.

πŸš€ Getting Started Prerequisites

You need to have Node.js installed on your system.

Installation

Clone the repository (assuming this code is in a repo):

Bash git clone [repository-url] cd [project-folder] Ensure all files are present: This server requires the following files in the root directory:

. β”œβ”€β”€ server.js β”œβ”€β”€ index.html β”œβ”€β”€ about.html └── styles.css (optional, but linked) Running the Server

Execute the server file using Node:

Bash node server.js You will see the confirmation message in your console:

Server running at http://localhost:3000 Open your browser and navigate to:

Home Page: http://localhost:3000/

About Page: http://localhost:3000/about

404 Test: http://localhost:3000/contact

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published