node实验代码

来源:互联网 发布:中世纪2mod原版优化9 编辑:程序博客网 时间:2024/06/05 16:42
//requier表示引包,引包就是引用自己的一个特殊功能var http = require('http');//创建服务器参数是一个回调函数,表示如果有请求进来要做什么http.createServer(function handler(req, res) {    //res表示请求,request;res表示响应,response    //设置HTTP头部信息,状态码200,文件类型是“text/html” 字符集是utf8    res.writeHead(200, {'Content-Type': 'text/plain'});    res.end('Hello World\n');}).listen(1337, '127.0.0.1');console.log('Server running at http://127.0.0.1:1337/');
0 0
原创粉丝点击