用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

原文出处:http://www.dongblog.com/notes/16.html
来源:博客网 转载请注明出处!

活跃用户

丶小葵
Ta还没有签名
wheein
Ta还没有签名
卡多雷的宅
Ta还没有签名
杰克韦尔奇
Ta还没有签名

友情链接


Warning: Smarty error: unable to read resource: "../../../templates/default/./common/foot/footer_index.htm" in /usr/home/hyu3925200001/htdocs/common/smarty/Smarty.class.php on line 1093

Warning: Smarty error: unable to read resource: "../../../templates/default/./common/foot/footer_index.htm" in /usr/home/hyu3925200001/htdocs/common/smarty/Smarty.class.php on line 1093