From 7dd5e4f16734dae80756c170c2680c98f6679368 Mon Sep 17 00:00:00 2001 From: yuto0214w Date: Sun, 7 Nov 2021 18:41:26 +0900 Subject: Update node_server_without_framework --- .../es/learn/server-side/node_server_without_framework/index.html | 5 ++--- .../ja/learn/server-side/node_server_without_framework/index.html | 4 ++-- .../ko/learn/server-side/node_server_without_framework/index.html | 7 +++---- .../ru/learn/server-side/node_server_without_framework/index.html | 5 ++--- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/files/es/learn/server-side/node_server_without_framework/index.html b/files/es/learn/server-side/node_server_without_framework/index.html index 11826d3e73..c103f58774 100644 --- a/files/es/learn/server-side/node_server_without_framework/index.html +++ b/files/es/learn/server-side/node_server_without_framework/index.html @@ -33,7 +33,6 @@ http.createServer(function (request, response) { } var extname = String(path.extname(filePath)).toLowerCase(); - var contentType = 'text/html'; var mimeTypes = {   '.html': 'text/html', '.js': 'text/javascript', @@ -51,13 +50,13 @@ http.createServer(function (request, response) { '.svg': 'application/image/svg+xml' }; - contentType = mimeTypes[extname] || 'application/octet-stream'; + var contentType = mimeTypes[extname] || 'application/octet-stream'; fs.readFile(filePath, function(error, content) { if (error) { if(error.code == 'ENOENT'){ fs.readFile('./404.html', function(error, content) { - response.writeHead(200, { 'Content-Type': contentType }); + response.writeHead(404, { 'Content-Type': 'text/html' }); response.end(content, 'utf-8'); }); } diff --git a/files/ja/learn/server-side/node_server_without_framework/index.html b/files/ja/learn/server-side/node_server_without_framework/index.html index a7ca7493b5..a59228be80 100644 --- a/files/ja/learn/server-side/node_server_without_framework/index.html +++ b/files/ja/learn/server-side/node_server_without_framework/index.html @@ -65,7 +65,7 @@ http.createServer(function (request, response) { if (error) { if(error.code == 'ENOENT') { fs.readFile('./404.html', function(error, content) { - response.writeHead(200, { 'Content-Type': contentType }); + response.writeHead(404, { 'Content-Type': 'text/html' }); response.end(content, 'utf-8'); }); } @@ -143,7 +143,7 @@ var contentType = mimeTypes[extname] || 'application/octet-stream';
if(error.code == 'ENOENT') {
     fs.readFile('./404.html', function(error, content) {
-        response.writeHead(200, { 'Content-Type': contentType });
+        response.writeHead(404, { 'Content-Type': 'text/html' });
         response.end(content, 'utf-8');
     });
 }
diff --git a/files/ko/learn/server-side/node_server_without_framework/index.html b/files/ko/learn/server-side/node_server_without_framework/index.html
index 43380d7e1a..26188a064a 100644
--- a/files/ko/learn/server-side/node_server_without_framework/index.html
+++ b/files/ko/learn/server-side/node_server_without_framework/index.html
@@ -19,7 +19,7 @@ original_slug: Node_server_without_framework
 
 

다음은 짧고 간단한 정적 파일 nodejs 서버입니다.

-
var http = require('http');
+
var http = require('http');
 var fs = require('fs');
 var path = require('path');
 
@@ -31,7 +31,6 @@ http.createServer(function (request, response) {
         filePath = './index.html';
 
     var extname = String(path.extname(filePath)).toLowerCase();
-    var contentType = 'text/html';
     var mimeTypes = {
         '.html': 'text/html',
         '.js': 'text/javascript',
@@ -49,13 +48,13 @@ http.createServer(function (request, response) {
         '.svg': 'application/image/svg+xml'
     };
 
-    contentType = mimeTypes[extname] || 'application/octet-stream';
+    var contentType = mimeTypes[extname] || 'application/octet-stream';
 
     fs.readFile(filePath, function(error, content) {
         if (error) {
             if(error.code == 'ENOENT'){
                 fs.readFile('./404.html', function(error, content) {
-                    response.writeHead(200, { 'Content-Type': contentType });
+                    response.writeHead(404, { 'Content-Type': 'text/html' });
                     response.end(content, 'utf-8');
                 });
             }
diff --git a/files/ru/learn/server-side/node_server_without_framework/index.html b/files/ru/learn/server-side/node_server_without_framework/index.html
index 4580af4317..87770c9825 100644
--- a/files/ru/learn/server-side/node_server_without_framework/index.html
+++ b/files/ru/learn/server-side/node_server_without_framework/index.html
@@ -36,7 +36,6 @@ http.createServer(function (request, response) {
     }
 
     var extname = String(path.extname(filePath)).toLowerCase();
-    var contentType = 'text/html';
     var mimeTypes = {
         '.html': 'text/html',
         '.js': 'text/javascript',
@@ -54,13 +53,13 @@ http.createServer(function (request, response) {
         '.svg': 'application/image/svg+xml'
     };
 
-    contentType = mimeTypes[extname] || 'application/octet-stream';
+    var contentType = mimeTypes[extname] || 'application/octet-stream';
 
     fs.readFile(filePath, function(error, content) {
         if (error) {
             if(error.code == 'ENOENT'){
                 fs.readFile('./404.html', function(error, content) {
-                    response.writeHead(200, { 'Content-Type': contentType });
+                    response.writeHead(404, { 'Content-Type': 'text/html' });
                     response.end(content, 'utf-8');
                 });
             }
-- 
cgit v1.2.3-54-g00ecf