diff --git a/app/zadanie01.js b/app/zadanie01.js
index 8c20173..98294f7 100644
--- a/app/zadanie01.js
+++ b/app/zadanie01.js
@@ -1 +1,20 @@
-//Twój kod
\ No newline at end of file
+const express = require('express');
+const bodyParser = require('body-parser');
+const app = express();
+app.use(bodyParser.urlencoded({extended:false}));
+app.use(express.static('./public/zadanie01'));
+
+app.post('/result', (req, res) => {
+ const {firstNumb,secondNumb} = req.body;
+ let result = '';
+ if(parseInt(firstNumb) % parseInt(secondNumb)){
+ result = `${firstNumb} jest dzielnikiem ${secondNumb}`;
+ }else{
+ result = `${firstNumb} nie jest dzielnikiem ${secondNumb}`;
+ }
+ res.send(result);
+});
+
+app.listen(3000,()=>{
+ console.log('Serwer uruchomiony na porcie 3000');
+});
diff --git a/app/zadanie02.js b/app/zadanie02.js
index 8c20173..8d24b97 100644
--- a/app/zadanie02.js
+++ b/app/zadanie02.js
@@ -1 +1,30 @@
-//Twój kod
\ No newline at end of file
+const express = require('express');
+const bodyParser = require('body-parser');
+const cookieParser = require('cookie-parser');
+const app = express();
+app.use(express.static('./public/zadanie02'));
+app.use(bodyParser.urlencoded({extended:false}));
+app.use(cookieParser());
+
+app.post('/cookie/set',(req,res)=>{
+ const {name} = req.body;
+ res.cookie('newName', name,{
+ maxAge : 31536000000,
+ });
+ res.send('Zapisano imię: ' + name);
+});
+app.get('/cookie/show',(req,res)=>{
+ const myCookie = req.cookies.newName;
+ res.send('Zapisane imię: ' + myCookie);
+});
+app.get('/cookie/check',(req,res)=>{
+ const myCookie = req.cookies.newName;
+ if(myCookie === undefined){
+ res.send('Brak zapisanego imienia!');
+ } else{
+ res.send('Zapisane imię: '+myCookie);
+ }
+});
+app.listen(3000,()=>{
+ console.log('Serwer uruchomiony na porcie 3000');
+});
diff --git a/app/zadanieDnia.js b/app/zadanieDnia.js
index 8c20173..bf459dc 100644
--- a/app/zadanieDnia.js
+++ b/app/zadanieDnia.js
@@ -1 +1,35 @@
-//Twój kod
\ No newline at end of file
+const express = require('express');
+const cookieParser = require('cookie-parser');
+const bodyParser = require('body-parser');
+
+const app = express();
+app.use(cookieParser());
+app.use(bodyParser.urlencoded({extended:false}));
+app.use(express.static('./public/zadanieDnia/'))
+
+app.post('/save', (req, res) => {
+ const allComments = addComment(req.cookies.comments, req.body.comment)
+
+ res.cookie('comments', allComments, {
+ maxAge : 31536000000,
+ });
+ res.send('Zapisano komentarz Powrót do strony głównej');
+});
+
+app.get('/', (req, res) => {
+ const comments = readComments(req.cookies.comments);
+ res.send(`${comments}Dodaj nowy komentarz`);
+});
+
+app.listen(3000, () => {
+ console.log('Serwer uruchomiony na porcie 3000');
+});
+
+function addComment(commentsCookieValue, newComment) {
+ const comments = readComments(commentsCookieValue);
+ comments.push(newComment);
+ return JSON.stringify(comments);
+}
+function readComments(commentsCookieValue) {
+ return commentsCookieValue ? JSON.parse(commentsCookieValue) : [];
+}