From 8dbac85d8d2133d44c1c6694e42e8f42c663696a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Woz=CC=81niak?= Date: Thu, 1 Feb 2018 13:30:10 +0100 Subject: [PATCH] fun with js #4 --- app/zadanieDnia1.js | 11 ++++++++++- app/zadanieDnia2.js | 12 +++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/zadanieDnia1.js b/app/zadanieDnia1.js index 8c20173..d179ba4 100644 --- a/app/zadanieDnia1.js +++ b/app/zadanieDnia1.js @@ -1 +1,10 @@ -//Twój kod \ No newline at end of file +const http = require("http"); + +const srv = http.createServer((req, res) => { + res.setHeader("Content-Type", "text/html; charset=utf-8"); + res.end("Hello, World from back-end!"); +}); + +srv.listen(3000, () => { + console.log("Serwer działa..."); +}); \ No newline at end of file diff --git a/app/zadanieDnia2.js b/app/zadanieDnia2.js index 8c20173..c30df54 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 acceptLanguage = req.headers['accept-language']; + res.setHeader("Content-Type", "text/html; charset=utf-8"); + res.end("Preferowane języki: " + acceptLanguage); +}); + +srv.listen(3000, () => { + console.log("Serwer działa..."); +}); \ No newline at end of file