Created
August 31, 2018 11:21
-
-
Save tom-field/dcc93a77b47bc4c412647653350cda37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//引入http模块 | |
var http = require("http"); | |
//设置主机名 | |
var hostName = '192.168.20.202'; | |
//设置端口 | |
var port = 8094; | |
//创建服务 | |
var server = http.createServer(function(req,res){ | |
res.setHeader('Content-Type','text/plain'); | |
res.end("hello nodejs"); | |
}); | |
server.listen(port,hostName,function(){ | |
console.log(`服务器运行在http://${hostName}:${port}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment