Node.js http模块 设置响应头
来源:互联网 发布:夏普哪个好 知乎 编辑:程序博客网 时间:2024/05/22 09:49
//运用这个案例简单讲解http//引用模块var http = require("http");//创建一个服务器,回调函数表示接受到请求之后做的事情var server = http.createServer(function(req,res){ //req参数表示请求,res表示响应 console.log("服务器接受到了请求"+req.url); //设置一个响应头 // res.writeHead(200,{"Content-Type":"text/plain;charset=UTF-8"});//纯文本 res.write("<h1>我是1标题</h1>"); res.write("<h2>我是2标题</h2>"); res.write("<h3>我是3标题</h3>"); res.write("<h4>我是4标题</h4>"); res.write("<h5>我是5标题</h5>"); res.write((1+2+3).toString()); res.end("<h1>我是一个主标题</h1>");});//监听端口server.listen(3000,"127.0.0.1");
res.writeHead(200,{"Content-Type":"text/plain;charset=UTF-8"});//纯文本
res.writeHead(200,{"Content-Type":"text/html;charset=UTF-8"});//超文本
0 0
- Node.js http模块 设置响应头
- Node.js开发 ---- 设置HTTP响应头解决跨域
- Node.js HTTP模块
- Ruby设置HTTP响应头
- nginx设置HTTP响应头
- Node.js 的 http 模块
- Node.js中的HTTP模块
- node.js的http模块
- Node.js基本模块http
- Node.js HTTP模块与事件模块
- Tornado设置http的响应头header
- node.js+android http请求响应
- node.js+android http请求响应
- node.js+Android http请求响应
- node.js+Android http请求响应
- Servlet处理HTTP响应(设置响应头)
- php设置http请求头信息和响应头信息
- node.js fs,http 模块用法
- Action通配符使用
- [LeetCode] 115. Distinct Subsequences
- leetcode 226. Invert Binary Tree
- 数据绑定之 Source, RelativeSource和ElementName的不同
- 记我的学习之路
- Node.js http模块 设置响应头
- 微软雅黑Monaco字体——听说是最适合编程的字体
- Openjudge 1.8 25:螺旋加密
- JAVA中编码格式问题
- Spring基础:在WebApplicationContext创建前和创建后调用方法
- AFN上传多张图片到服务器
- 在Linux中使用U盘
- 关于从eclipse中导入到AS进行分包的问题汇总
- LintCode : 搜索旋转排列数组