From 8a54cce9efe8bad8a0e3d80adb4b7d771dcc5b6e Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Thu, 28 Jul 2022 20:46:51 +0200 Subject: add exercise --- Year_3/Web/math/index.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Year_3/Web/math/index.js (limited to 'Year_3/Web/math/index.js') diff --git a/Year_3/Web/math/index.js b/Year_3/Web/math/index.js new file mode 100644 index 0000000..db3f304 --- /dev/null +++ b/Year_3/Web/math/index.js @@ -0,0 +1,24 @@ +const express = require("express"); + +const app = express(); + +app.use(express.urlencoded({ extended: false })); +app.use(express.json()); + +app.get("/", (req, res) => { + res.json({ result: 0 }); +}); + +app.post("/calculate", (req, res) => { + const { value1, value2 } = req.body; + + res + .status(200) + .json({ + param1: Number(value1), + param2: Number(value2), + result: Number(value1) + Number(value2), + }); +}); + +app.listen(3000); -- cgit v1.2.3-18-g5258