博主:DongJiang
码龄:7年
等级:
文章:631
访问:52336
博客简介:DongJiang的博客
博客创建时间:2018-04-12
给博主送颗小红心
1002
后台管理系统: 进入后台

用nodejs实现httpserver服务

//导入模块是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

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