diff options
Diffstat (limited to 'files/ko/learn/server-side/node_server_without_framework/index.html')
-rw-r--r-- | files/ko/learn/server-side/node_server_without_framework/index.html | 7 |
1 files changed, 3 insertions, 4 deletions
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 <p>다음은 짧고 간단한 정적 파일 nodejs 서버입니다.</p> -<pre>var http = require('http'); +<pre class="brush: js">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'); }); } |