diff --git a/app/zadanieDnia1.js b/app/zadanieDnia1.js index 8c20173..6e0087c 100644 --- a/app/zadanieDnia1.js +++ b/app/zadanieDnia1.js @@ -1 +1,9 @@ -//Twój kod \ No newline at end of file +//Twój kod +const http = require('http'); + +const server = http.createServer((req, res) => { + res.setHeader('Content-type', 'text/html; charset=utf8'); + res.end('Hello, World from back-end!'); +}); + +server.listen(3000); \ No newline at end of file diff --git a/app/zadanieDnia2.js b/app/zadanieDnia2.js index 8c20173..cc289a4 100644 --- a/app/zadanieDnia2.js +++ b/app/zadanieDnia2.js @@ -1 +1,21 @@ -//Twój kod \ No newline at end of file +//Twój kod +const http = require('http'); + +const server = http.createServer((req, res) => { + console.log('request'); + const userAgent = req.headers['user-agent']; + const accept = req.headers['accept']; + + res.setHeader('Content-type', 'text/html; charset=utf8'); + res.end( + `

Hi!

+

Your user-agent is:

${userAgent}

+

You accept:

${accept}

+

You used a method:

${req.method}

+

All there is:

${JSON.stringify(req.headers)}

` + ); +}); + +server.listen(3000, () => { + console.log('server on port 3000'); +}); \ No newline at end of file