From e654d89f11ea5e75d4c4ad24cf74a4d1dc4e8238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Dadlez?= Date: Thu, 1 Feb 2018 22:32:13 +0100 Subject: [PATCH] =?UTF-8?q?rozwi=C4=85zania?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/zadanieDnia1.js | 10 +++++++++- app/zadanieDnia2.js | 22 +++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) 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