nodejs部署服务监听端口

//导入包
const http = require("http");
const {
    Http2ServerRequest
} = require("http2");

 

//1:创建一个服务
http.createServer(function (request, response) {
    //浏览器怎么认识hello server
    response.writeHead(200, {
        'Content-type': 'text/html'
    })
    //给浏览器输出类容
    response.end("<strong>hello server<strong>")
}).listen(8888);
console.log("你启动的服务是:http:localhost:8888已启动成功")
//2:监听一个端口:8888
//3:启动 node 文件名httpserver
//4: 浏览器访问 http:localhost:8888
 
//node xxx.js
posted @ 2021-03-12 09:23  cloudAlexander  阅读(583)  评论(0)    收藏  举报