Skip to content

Instantly share code, notes, and snippets.

@tom-field
Created August 31, 2018 11:21
Show Gist options
  • Save tom-field/dcc93a77b47bc4c412647653350cda37 to your computer and use it in GitHub Desktop.
Save tom-field/dcc93a77b47bc4c412647653350cda37 to your computer and use it in GitHub Desktop.
//引入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