diff --git a/assignments/hackyourtemperature/.idea/.gitignore b/assignments/hackyourtemperature/.idea/.gitignore new file mode 100644 index 000000000..1c2fda565 --- /dev/null +++ b/assignments/hackyourtemperature/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/assignments/hackyourtemperature/.idea/hackyourtemperature.iml b/assignments/hackyourtemperature/.idea/hackyourtemperature.iml new file mode 100644 index 000000000..0b872d82d --- /dev/null +++ b/assignments/hackyourtemperature/.idea/hackyourtemperature.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/assignments/hackyourtemperature/.idea/modules.xml b/assignments/hackyourtemperature/.idea/modules.xml new file mode 100644 index 000000000..51ab5ccc4 --- /dev/null +++ b/assignments/hackyourtemperature/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/assignments/hackyourtemperature/.idea/vcs.xml b/assignments/hackyourtemperature/.idea/vcs.xml new file mode 100644 index 000000000..2e3f6920d --- /dev/null +++ b/assignments/hackyourtemperature/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/assignments/hackyourtemperature/package.json b/assignments/hackyourtemperature/package.json new file mode 100644 index 000000000..ea86a9575 --- /dev/null +++ b/assignments/hackyourtemperature/package.json @@ -0,0 +1,23 @@ +{ + "name": "hackyourtemperature", + "type": "module", + "version": "1.0.0", + "description": "", + "main": "server.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "start": "node server.js", + "dev": "nodemon server.js" + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "express": "^5.1.0", + "nodemon": "^3.1.10" + }, + "dependencies": { + "express-handlebars": "^8.0.3", + "node-fetch": "^3.3.2" + } +} diff --git a/assignments/hackyourtemperature/server.js b/assignments/hackyourtemperature/server.js new file mode 100644 index 000000000..292bfa560 --- /dev/null +++ b/assignments/hackyourtemperature/server.js @@ -0,0 +1,23 @@ +import express from 'express'; + +const app = express(); + +app.use(express.json()); + +//GET request that sends the message [hello from backend to frontend!] to the client +app.get('/', (req, res) => { + res.send('Hello From Backend to Frontend'); +}); + +//5.1 Adding a POST request + +app.post('/weather', (req, res) => { + console.log(req.body); + const { cityName } = req.body; + res.json(`the city name is ${cityName} `); +}); + +// +app.listen(3000, () => { + console.log('Server on Port 300 is running'); +});