nodejs学习笔记一

一、建立一个http web服务器,并返回Hello World!node

复制代码
const http = require('http');

http.createServer( (request, response) => {
  response.writeHead(200, {'Content-Type': 'text/plain'});
  response.end('Hello World\n');
}).listen(8888);

console.log('Server running at http://127.0.0.1:8888/');
复制代码

二、启动服务器,在浏览器中输入http://127.0.0.1:8888/,页面显示Hello World。web

$ node example.js
Server running at http://127.0.0.1:8888/

 

相关文章
相关标签/搜索