欢迎来到Anderson_An的博客

🌵点此关注哟
众里寻他千百度,蓦然回首,那人却在灯火阑珊处

linux系统下开启一个简单的web服务

linux 下开启一个简单的web服务:

 

首先需要linux下安装nodejs

 

然后创建一个test.js:   vi test.js

var http =require("http");
function hello(req,res){
        res.writeHead(200,{"content-type":"text/plain"});
        res.end("hello, word");
}
http.createServer(hello).listen(12306,"192.168.0.108");

console.log("hello, word");

保存退出后执行:node test,js

客户端打开浏览器输入:192.168.0.108:12306 即可看到浏览器输出结果:

hello, word

posted on 2018-12-15 20:28  Anderson_An  阅读(2990)  评论(0编辑  收藏  举报

导航