final
This commit is contained in:
11
task13/1/about.html
Normal file
11
task13/1/about.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>О сайте</title>
|
||||
<meta charset="utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>О сайте</h1>
|
||||
</body>
|
||||
<html></html>
|
||||
</html>
|
||||
20
task13/1/app.js
Normal file
20
task13/1/app.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const http = require('http');
|
||||
const fs = require('fs');
|
||||
|
||||
http.createServer(function (request, response) {
|
||||
console.log(`Запрошенный адрес: ${request.url}`);
|
||||
// получаем путь после слеша
|
||||
const filePath = request.url.substr(1);
|
||||
// смотрим, есть ли такой файл
|
||||
fs.access(filePath, fs.constants.R_OK, (err) => {
|
||||
// если произошла ошибка - отправляем статусный код 404
|
||||
if (err) {
|
||||
response.statusCode = 404;
|
||||
response.end('Resourse not found!');
|
||||
} else {
|
||||
fs.createReadStream(filePath).pipe(response);
|
||||
}
|
||||
});
|
||||
}).listen(3000, function () {
|
||||
console.log('Server started at 3000');
|
||||
});
|
||||
16
task13/1/index.html
Normal file
16
task13/1/index.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Главная</title>
|
||||
<meta charset="utf-8" />
|
||||
<link
|
||||
href="publc/styles.css"
|
||||
rel="stylesheet"
|
||||
type="text/css"
|
||||
/>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Главная</h1>
|
||||
</body>
|
||||
<html></html>
|
||||
</html>
|
||||
4
task13/1/publc/styles.css
Normal file
4
task13/1/publc/styles.css
Normal file
@@ -0,0 +1,4 @@
|
||||
body {
|
||||
font-family: Verdana;
|
||||
color: rgb(48, 48, 92);
|
||||
}
|
||||
11
task13/2/about.html
Normal file
11
task13/2/about.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>О сайте</title>
|
||||
<meta charset="utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>О сайте</h1>
|
||||
</body>
|
||||
<html></html>
|
||||
</html>
|
||||
18
task13/2/app.js
Normal file
18
task13/2/app.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const http = require('http');
|
||||
const fs = require('fs');
|
||||
|
||||
http.createServer(function (request, response) {
|
||||
console.log(`Запрошенный адрес: ${request.url}`);
|
||||
// получаем путь после слеша
|
||||
const filePath = request.url.substr(1);
|
||||
fs.readFile(filePath, function (error, data) {
|
||||
if (error) {
|
||||
response.statusCode = 404;
|
||||
response.end('Resourse not found!');
|
||||
} else {
|
||||
response.end(data);
|
||||
}
|
||||
});
|
||||
}).listen(3000, function () {
|
||||
console.log('Server started at 3000');
|
||||
});
|
||||
16
task13/2/index.html
Normal file
16
task13/2/index.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Главная</title>
|
||||
<meta charset="utf-8" />
|
||||
<link
|
||||
href="publc/styles.css"
|
||||
rel="stylesheet"
|
||||
type="text/css"
|
||||
/>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Главная</h1>
|
||||
</body>
|
||||
<html></html>
|
||||
</html>
|
||||
4
task13/2/publc/styles.css
Normal file
4
task13/2/publc/styles.css
Normal file
@@ -0,0 +1,4 @@
|
||||
body {
|
||||
font-family: Verdana;
|
||||
color: rgb(48, 48, 92);
|
||||
}
|
||||
Reference in New Issue
Block a user