π 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