Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Day5 #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Day5 #10

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
express = require('express');
const app = express();

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

app.get('/:a/:b', (req, res) => {
const wynik = parseInt(req.params.a) + parseInt(req.params.b);
res.send('Wynik sumowania to: ' + wynik);
});

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

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

let imie;
let flag = false;

app.get('/name/set/:imie', (req, res) => {
imie = req.params.imie;
flag = true;
res.send('Set - Podane imie to: ' + imie);
});

app.get('/name/show', (req, res) => {
if (flag === true){
res.send('Show - Podane imie to: ' + imie);
} else {
res.send('Nie zdefiniowano jeszcze imienia.')
}
});

app.get('/name/check', (req, res) => {
if (flag === false){
res.send('Imie nie zostalo jeszcze zdefiniowane');
} else {
res.send('Check - Podane imie to: ' + imie);
}

});

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

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

let yes = 0;
let no = 0;

app.get('/vote/yes', (req, res) => {
yes++;
res.send('Cieszy mnie Twoja pozytywna opinia.');
});

app.get('/vote/no', (req, res) => {
no++;
res.send('Szkoda, dzięki za głos.');
});

app.get('/votes/check', (req, res) => {
res.send('Wyniki głosowanie - ' + yes + ' głosowało na tak, a ' + no + ' głosowało na nie.');
});

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