'nodejs'에 해당하는 글 1건

nodejs에 대한 이미지 검색결과


nodejs http basic smaple

1
2
3
4
5
6
7
var http = require('http');
 
http.createServer(function(request, response) {
  response.writeHead(200);
  response.write('Hello, Nodejs');
  response.end();
}).listen(8080);
cs



Read file Blocking code sample


1
2
3
4
var fs = require('fs');
 
var contents = fs.readFileSync('index.html');
console.log(contents);
cs



Read file Non-blocking code sample


1
2
3
fs.readFile('index.html',function(error,contents){
  console.log(contents);
});
cs



Read file in server


1
2
3
4
5
6
7
8
9
10
var http = require('http');
var fs = require('fs');
 
http.createServer(function(request, response) {
  response.writeHead(200,{
'Content-Type' : 'text/html'
});
  fs.readFile('index.html',function(error ,contents){
    response.write(contents);
    response.end();
  }); 
}).listen(8080);

cs



WRITTEN BY
라프르

,