2.1.3 • Published 1 year ago

re-002kjnml v2.1.3

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

README.md


HTTP Server with Route Handling

This Node.js script sets up an HTTP server capable of routing different requests based on their paths. Below is an overview of its functionalities:

Features:

  1. Server Setup: The script initializes an HTTP server using Node.js's built-in http module.

  2. Route Handling:

    • Root Route (/): Serves the index.html file when accessed directly or when /index.html is requested.
    • /tasks Route: Sends JSON data stored in a tasks.json file when accessed.
    • 404 Route: Returns a 404 Not Found error message for any other requested paths.
  3. Error Handling: Proper error handling is implemented for scenarios such as file reading errors or unknown paths, ensuring graceful error responses.

  4. Server Startup: The server is configured to listen on port 3000, and a message is logged to the console upon successful startup.

Usage:

  1. Clone the repository.
  2. Install dependencies (if any).
  3. Run the script using Node.js.
  4. Access the server endpoints via a web browser or HTTP client.

Requirements:

  • Node.js installed on the system.

Dependencies:

  • None (core Node.js modules are used).

File Structure:

project-directory/
│
├── index.js
├── index.html
├── tasks.json
└── README.md

License:

This project is licensed under the MIT License. See the LICENSE file for details.

Author:

Created by Your Name (Your GitHub Profile(Your GitHub Profile Link))