함수 호출

//   
var http = require("http");
var otherfun = require("./models/otherfuns.js");    //      
http.createServer(function (request, response) {
    response.writeHead(200,  {'Content-Type': 'text/html; charset=utf-8'}); //   
    if(request.url !== "/favicon.ico") { //       
        fun1(response);     //      
        otherfun.fun2(response);    //      
        otherfun.fun3(response);
        response.end("");   //   
    }
}).listen(8000);
console.log("Server running at http://127.0.0.1:8000/"); 

function fun1(res) {
    console.log("fun1");
    res.write("hello,  fun1");
}

//    
module.exports = {
    fun2: function (res) {
        console.log("fun2");
        res.write("hello,  fun2");
    },
    fun3: function (res) {
        console.log("fun3");
        res.write("hello,  fun3");
    }
};

좋은 웹페이지 즐겨찾기