From 48e7ba63cf32d0cd1e8505cc32951e5d8e24145c Mon Sep 17 00:00:00 2001 From: abhishektiwari003 Date: Thu, 23 Apr 2026 17:47:16 +0530 Subject: [PATCH] changes testing env --- app.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index f26fab1..c533b74 100644 --- a/app.js +++ b/app.js @@ -3,9 +3,16 @@ const http = require("http"); const PORT = 8080; const server = http.createServer((req, res) => { - if (req.method === "GET" && req.url === "/") { - res.writeHead(200, { "Content-Type": "text/plain" }); - res.end("Now push the code disconnected as I shown o"); + const parsedUrl = new URL(req.url, `http://${req.headers.host}`); + + if (req.method === "GET" && parsedUrl.pathname === "/") { + const key = parsedUrl.searchParams.get("key"); + const response = key + ? { message: "added to the response", value: key } + : { message: "key query param not found" }; + + res.writeHead(200, { "Content-Type": "application/json" }); + res.end(JSON.stringify(response)); } else { res.writeHead(404, { "Content-Type": "text/plain" }); res.end("Not Found");