이찬

연습중인 node js

Showing 1 changed file with 17 additions and 0 deletions
1 +var http = require('http');
2 +var fs = require('fs');
3 +var url = require('url');
4 +
5 +var app = http.createServer(function (request, response) {
6 + var _url = request.url;
7 + if (_url == '/') {
8 + _url = '/index.html';
9 + }
10 + if (_url == '/favicon.ico') {
11 + return response.writeHead(404);
12 + }
13 + response.writeHead(200);
14 + response.end(fs.readFileSync(__dirname + _url));
15 +
16 +});
17 +app.listen(3000);
...\ No newline at end of file ...\ No newline at end of file