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
16 changes: 15 additions & 1 deletion app/zadanie01.js
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
//Twój kod
const express = require('express');
const app = express();

app.get('/', (req, res) => {
res.send('Podaj 2 liczby w URL');
});

app.get('/:first/:second', (req, res) => {
const sum = parseInt(req.params.first) + parseInt(req.params.second);
res.send('Suma ' + req.params.first + ' i ' + req.params.second + ' to: ' + sum);
});

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

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

let names = [];

app.get('/name/set/:imie', (req, res) => {
names.push(req.params.imie);
res.send(`Imię ${req.params.imie} dodane.`);
});

app.get('/name/show', (req, res) => {
res.send('Aktualne imię to: ' + names[names.length-1]);
});

app.get('/name/check/:imie', (req, res) => { //poprawiona ścieżka
names.indexOf(req.params.imie) < 0 ?
res.send(`Imię ${req.params.imie} nie zostało jeszcze zapisane.`) :
res.send(`Imię ${req.params.imie} zostało już zapisane.`);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ciekawe podejście do zadania :)


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

let votes = {};

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

app.get('/vote/:option', (req, res) => {
let {option} = req.params;
votes[option] = votes[option] + 1 || 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super, krótko i uniwersalnie

res.send('Dziękujemy za głos!');
});

app.get('/votes/check', (req, res) => {
let results = "";
for (let option in votes) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super

results += `${option} : ${votes[option]}<br>`;
}
res.send(results);
});

app.listen(3000, () => {
console.log('Serwer uruchomiony na porcie 3000');
});