From ccd0bcd48b60575ef0753a0ef6aa8b52e82a8150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Bu=C5=82ka?= Date: Thu, 1 Feb 2018 20:49:46 +0000 Subject: [PATCH] Day4 --- app/zadanieDnia1.js | 15 ++++++++++++++- app/zadanieDnia2.js | 12 +++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/app/zadanieDnia1.js b/app/zadanieDnia1.js index 8c20173..f63f7a8 100644 --- a/app/zadanieDnia1.js +++ b/app/zadanieDnia1.js @@ -1 +1,14 @@ -//Twój kod \ No newline at end of file +//Twój kod + +const http = require('http'); + +const srv = http.createServer((req, res) => { + + res.setHeader("Content-Type", "text/html; charset=utf-8"); + res.end('

Hello World

'); + +}); + +srv.listen(3000, () => { + +}); \ No newline at end of file diff --git a/app/zadanieDnia2.js b/app/zadanieDnia2.js index 8c20173..1b46fb3 100644 --- a/app/zadanieDnia2.js +++ b/app/zadanieDnia2.js @@ -1 +1,11 @@ -//Twój kod \ No newline at end of file +const http = require('http'); + +const srv = http.createServer((req, res) => { + const browser = req.headers['user-agent']; + res.setHeader("Content-Type", "text/html; charset=utf-8"); + res.end('

Hello ' + browser + '

'); +}); + +srv.listen(3000, () => { +console.log("Serwer wystartowal"); +}); \ No newline at end of file