node.js - 有什么好的开源nodejs服务器解决方案?
迷茫
迷茫 2017-04-17 15:19:11
0
2
376

    createServer();

function createServer(){

    var http = nodeRequire("http");
    http.createServer(function(request, response) {

        let path = request.url;
        response.writeHead(200, {"Content-Type": "text/html"});
        let fs = nodeRequire("fs");
        let data = fs.readFileSync(app_dir+path);
        response.write(data.toString());
        response.end();

    }).listen(8888);

}

就像这样,输出一个html文件,跟正常访问一样,不过遇到css、js什么都要自己判断。应该有现成的轮子可用了,推荐一个吧?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(2)
洪涛

express

小葫芦

See awesome-nodejs

for details
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template