diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..504afef81fbadc8c0a072e1ac93f1376bca7f4a9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +package-lock.json diff --git a/Assignment2_step2.png b/Assignment2_step2.png new file mode 100644 index 0000000000000000000000000000000000000000..80bf8b7a621f0845a8e3402d463f3644e1f847df Binary files /dev/null and b/Assignment2_step2.png differ diff --git a/PostMethod_illustrate_using_CURL_Command.png b/PostMethod_illustrate_using_CURL_Command.png new file mode 100644 index 0000000000000000000000000000000000000000..15a24abedd2c2190fe06792400829fcaddaa9d8a Binary files /dev/null and b/PostMethod_illustrate_using_CURL_Command.png differ diff --git a/asignment2_step1.png b/asignment2_step1.png new file mode 100644 index 0000000000000000000000000000000000000000..7cce3daa5a167476f884392e70fd8dc62a45fcd7 Binary files /dev/null and b/asignment2_step1.png differ diff --git a/package.json b/package.json new file mode 100644 index 0000000000000000000000000000000000000000..abdc2a85c6e53990f5625dfd326c0e4674d329bc --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "express": "^4.21.2" + } +} diff --git a/server.js b/server.js new file mode 100644 index 0000000000000000000000000000000000000000..0b4c51c9f2417bb90a9e17a7d9526d4d3cf860da --- /dev/null +++ b/server.js @@ -0,0 +1,29 @@ +const express = require("express"); +const app = express(); +const port = 3000; + +app.use(express.json()); + +app.get("/info/:pathParam", (req, res) => { + const pathParam = req.params.pathParam; + const queryParam = req.query.q; + + res.json({ + message: "GET API Response", + pathParam: pathParam, + queryParam: queryParam || "No query param provided" + }); +}); + +app.post("/data", (req, res) => { + const receivedData = req.body; + + res.json({ + message: "POST API Response", + dataArray: Array.isArray(receivedData) ? receivedData : [receivedData] + }); +}); + +app.listen(port, () => { + console.log(`Express Server is running on http://localhost:${port}`); +});