changes testing env

This commit is contained in:
Abhishek Test Tiwari 2026-04-23 17:47:16 +05:30
parent f3d97bd3c8
commit 48e7ba63cf

13
app.js
View File

@ -3,9 +3,16 @@ const http = require("http");
const PORT = 8080; const PORT = 8080;
const server = http.createServer((req, res) => { const server = http.createServer((req, res) => {
if (req.method === "GET" && req.url === "/") { const parsedUrl = new URL(req.url, `http://${req.headers.host}`);
res.writeHead(200, { "Content-Type": "text/plain" });
res.end("Now push the code disconnected as I shown o"); 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 { } else {
res.writeHead(404, { "Content-Type": "text/plain" }); res.writeHead(404, { "Content-Type": "text/plain" });
res.end("Not Found"); res.end("Not Found");