[头参数]01 - 搭建服务器
作者:
dyq666 | 来源:发表于
2018-06-29 23:14 被阅读0次
目录
- 使用node搭建http服务端
1. 使用node搭建http服务端
-
response.end
来返回数据。
- 端口号不要使用6666(只在谷歌浏览器中进行了测试,端口默认情况下是不能使用的)。
- 创建结束后使用
console.log
告诉终端http服务端搭建完成(异步的特性)。
- 完成后访问
localhost:9000
即可。
/**
* node.js创建服务端的基础
*/
const http = require('http')
const port = 9000
http.createServer(function(request, response) {
console.log(request.url)
response.end('666')
}).listen(port)
console.log(`listen ${port}`)
- 成功显示了内容。
- 浏览器发送的
favicon.ico
请求是网站的图标,这是浏览器的功能,这里不需要处理
本文标题:[头参数]01 - 搭建服务器
本文链接:https://www.haomeiwen.com/subject/rpfoyftx.html
网友评论