博主:DongJiang
码龄:7年
等级:LV.22级
文章:631
访问:5233623
博客简介:记录与分享
博客创建时间:2018-04-12
他的博客主页 立即前往

友情链接

用nodejs实现httpserver服务

来源: 2023-06-25 20:33:55
//导入模块是require 类似于import java.io
const http = require('http')

//创建httpserver服务
http
  .createServer(function (request, response) {
    //告诉浏览器将以text-plain去解析hello server
    response.writeHead(200, { 'Content-type': 'text/plain' })
    //输出内容给浏览器
    response.end('hello server!!!')
  })
  .listen(8888)
console.log('你启动的服务是:http://localhost:8888')
//监听端口8888
//启动运行服务器node httpserver.js
//浏览器访问http://localhost:8888

Description

Description

原文出处:
版权声明:本文来源地址若非本站均为转载,若侵害到您的权利,请及时联系我们,我们会在第一时间进行处理。