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
//Twój kod

const express = require('express');
const app = express();

app.get('/numbers/:number1/:number2', (req, res) => {
let number1 = parseInt(req.params.number1);
let number2 = parseInt(req.params.number2);
let sum = number1 + number2;
res.send(`<h1 style='text-align:center; border: 3px solid #000; margin-top: 50px; background-color: #CDCDCD;'>${number1} + ${number2} = ${sum}<h1>`);
});

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

const express = require('express');
const app = express();
const style = 'text-align:center; border: 3px solid #000; margin-top: 50px; background-color: #CDCDCD;';
let name;

app.get('/name/set/:imie', (req, res) => {
name = req.params.imie;
res.send(`<h1 style='${style}'>${name}<h1>`);
});

app.get('/name/show', (req, res) => {
let information = name !== undefined ? `You set name: ${name}` : 'Please set name first';
res.send(`<h1 style='${style}'>${information}<h1>`);
});

app.get('/name/check', (req, res) => {
let information = name !== undefined ? 'Name saved' : 'Name not saved';
res.send(`<h1 style='${style}'>${information}<h1>`);
});

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

const express = require('express');
const app = express();
let options = [];

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

app.get('/vote/:option', (req, res) => {
let option = req.params.option;

typeof options[option] === 'undefined' ? options[option] = 1 : options[option]++;
Copy link
Contributor

Choose a reason for hiding this comment

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

Brawo, bardzo uniwersalne

res.send(`<h1>Thank you for your vote</h1>`);
});

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

Choose a reason for hiding this comment

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

Super

voteResults += `<h1>Votes for ${option}: ${options[option]}<h1></br>`;
}
res.send(voteResults);
});

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