nodejs--http
来源:互联网 发布:java 开源项目源码 编辑:程序博客网 时间:2024/06/05 06:41
Htto模块主要是用来创建Web服务器来用的,使用Node进行创建服务器是相当简单的,现在简单的来写一个服务器
`var http = require(‘http’)
http.createServer(function(req,res){
res.writeHead(200),
res.end(‘hello-world’)
})
.listen(8080)
console.log(web is starting on 8080)`
这里的http.createServer方法呢接受一个函数,response.writeHead方法用来写入HTTP回应的头信息;response.end方法用来写入HTTP回应的具体内容,以及回应完成后关闭本次对话。最后的listen(8080)表示启动服务器实例,监听本机的8080端口
关于Http类似get,post之类的方法,会在后续学习里相继补充
0 0
- nodejs--http
- nodejs-http
- NodeJS-http
- NodeJS http.ServerRequest & http.ServerResponse
- NodeJS http.ClientRequest & http.ClientResponse
- nodejs--http篇
- nodejs 创建http客户端
- nodejs中的HTTP请求
- Nodejs http、url模块
- nodejs http 发送请求
- nodejs 创建http server
- http服务器(nodejs)
- nodejs http响应两次
- nodejs模块-http
- nodejs API之HTTP
- nodejs-http服务
- nodejs-http客户端
- nodejs http 发送请求
- Leetcode 162. Find Peak Element (Medium) (cpp)
- 分析优酷/土豆/pptv/乐视 HTML5、m3u8地址
- JHTP自测题_第十二章_GUI组件(上篇)
- python资料
- C++语法 : 内存池技术的原理与实现
- nodejs--http
- FILL bfs
- Java垃圾回收(一)对象存活状态判断---深入理解Java虚拟机
- Codeforces Round #209 (Div. 2) D - Pair of Numbers
- Swift闭包循环引用
- ORACLE数据库---"ORA-00942: 表或视图不存在 "的原因和解决方法
- python中静态方法和类方法的区别
- 旅行商问题(状态压缩dp)
- python脚本爬取今日百度热点新闻