Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
*.*~
node_modules
4 changes: 4 additions & 0 deletions app/public/zadanieDnia/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@

.vote.no {
background : red;
}

.vote.maybe {
background: hotpink;
}
1 change: 1 addition & 0 deletions app/public/zadanieDnia/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<h1>Zagłosuj: czy Node.js jest fajny?</h1>
<a href="/vote/yes" class="vote yes">Tak!</a>
<a href="/vote/no" class="vote no">Nie :(</a>
<a href="/vote/maybe" class="vote maybe">To się okaże</a>
<hr>
<a href="/votes/check">Sprawdź wyniki głosowania</a>
</body>
Expand Down
10 changes: 10 additions & 0 deletions app/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const express = require('express');
const app = express();

app.get('/', (req, res) => {
res.send('Hello, World!');
});

app.listen(3000, () => {
console.log('Serwer uruchomiony na porcie 3000');
});
8 changes: 8 additions & 0 deletions app/test2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const express = require('express');
const app = express();

app.use(express.static('./public/przykladStatyczne/'));

app.listen(3000, () => {
console.log('Serwer uruchomiony na porcie 3000');
});
14 changes: 13 additions & 1 deletion app/zadanie01.js
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
//Twój kod
const express = require('express');
const app = express();

app.get('/:num1/:num2', (req, res) => {
const num1 = req.params.num1;
const num2 = req.params.num2;
let sum = parseInt(num1) + parseInt(num2);
res.send('Suma liczb to ' + sum);
});

app.listen(3000, () => {
console.log('Serwer uruchomiony na porcie 3000');
});
21 changes: 20 additions & 1 deletion app/zadanie02.js
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
//Twój kod
const express = require('express');
const app = express();
let userName = '';

app.get('/name/set/:imie', (req, res) => {
userName = req.params.imie;
res.send('Twoje imię to ' + userName);
});

app.get('/name/show', (req, res) => {
res.send('Zapamiętałem Twoje imię: ' + userName);
});

app.get('/name/check', (req, res) => {
(userName !=='')? (res.send('Zapamiętałem Twoje imię: ' + userName)) : (res.send('Nie znam Twojego imienia :('));
});

app.listen(3000, () => {
console.log('Serwer uruchomiony na porcie 3000');
});
21 changes: 20 additions & 1 deletion app/zadanieDnia1.js
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
//Twój kod
const express = require('express');
const app = express();
let yesCounter = 0;
let noCounter = 0;
let maybeCounter = 0;
app.use(express.static('./public/zadanieDnia/'));
let pollCounter = ()=> {
app.get('/vote/:votetype', (req, res) => {
let votetype = req.params.votetype;
(votetype === 'yes') ? yesCounter++ : (votetype === 'no')? noCounter++ : maybeCounter++;
res.send('Dziękujemy za głos!');
});
app.get('/votes/check', (req, res) => {
res.send(`'Tak': ${yesCounter} 'Nie': ${noCounter} 'To się okaże': ${maybeCounter}`);
});
};
pollCounter();
app.listen(3000, () => {
console.log('Serwer uruchomiony na porcie 3000');
});
22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "challenge",
"version": "1.0.0",
"description": "<img alt=\"Logo\" src=\"https://coderslab.pl/svg/logo-coderslab.svg\" width=\"400\">",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/angorzan/Node.js_challenge_dzien_5.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/angorzan/Node.js_challenge_dzien_5/issues"
},
"homepage": "https://github.com/angorzan/Node.js_challenge_dzien_5#readme",
"dependencies": {
"express": "^4.16.2"
}
}