认识Node.JS第一步

Node.JS

Node.JS 是运行在服务端的JavaScript。

下面是一个小栗子:

const http = require('http');

http.createServer(function(req,res){
    
    
    // 发送 HTTP 头部
    // HTTP 状态值: 200 : OK
    // 内容类型: text/plain
    res.writeHead(200, {
    
    'Content-Type': 'text/plain'});

    // 发送响应数据 "Hello World"
    res.end('hello world');

}).listen(3000);
console.log('localhost:3000');

运行服务:
在这里插入图片描述

一个简单的服务就写好了:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_41481695/article/details/106324785