This is a simple Node.js application that mimics the behavior of httpstat.us. It allows you to define different HTTP status codes and returns a corresponding response. The responses can be customized by modifying the status codes array in the code.
- Node.js installed on your machine
-
Clone the repository or download the source code.
-
Open a terminal or command prompt and navigate to the project directory.
-
Run the following command to install the required dependencies:
npm install http
-
Start the server by running the following command:
node app.jsThe server will start running on port 3000.
-
Access different HTTP status codes by appending the desired code to
http://localhost:3000/. For example:http://localhost:3000/200will return a JSON response:{"code":200,"message":"OK"}.http://localhost:3000/201will return a JSON response:{"code":201,"message":"Created"}.http://localhost:3000/400will return a JSON response:{"code":400,"message":"Bad Request"}.
-
Customize the responses by modifying the
httpStatusCodesarray in theapp.jsfile. Each object in the array should have acodeandmessageproperty defining the HTTP status code and corresponding message, respectively.