Skip to content
Open
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
10 changes: 9 additions & 1 deletion app/zadanieDnia1.js
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
//Twój kod
//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);
22 changes: 21 additions & 1 deletion app/zadanieDnia2.js
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
//Twój kod
//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(
`<h1>Hi!</h1>
<h1 style='text-decoration: underline'>Your user-agent is:</h1><h2>${userAgent}</h2>
<h1 style='text-decoration: underline'>You accept:</h1><h2>${accept}</h2>
<h1 style='text-decoration: underline'>You used a method:</h1><h2>${req.method}</h2>
<h1 style='text-decoration: underline'>All there is:</h1><p>${JSON.stringify(req.headers)}</p>`
);
});

server.listen(3000, () => {
console.log('server on port 3000');
});