node.js入門執行個體helloworld詳解,

來源:互聯網
上載者:User

node.js入門執行個體helloworld詳解,

本文執行個體講述了node.js入門執行個體helloworld。分享給大家供大家參考,具體如下:

將下面的代碼儲存為:server.js存到E盤下面的node目錄中。

var http = require('http');function myNode(request, response){  response.writeHead(200, {'Content-type':'text/plain'});  response.write('hello world'); //hello world  response.end();}http.createServer(myNode).listen(2222); //監聽2222連接埠console.log('Server has started'); //在控制台提示服務啟動

然後在windows命令列輸入node e:/node/server.js

提示服務啟動(Server has started),然後在瀏覽器中輸入http://localhost:2222/,即可以看到的效果。

執行成功後的效果

希望本文所述對大家node.js程式設計有所協助。

您可能感興趣的文章:
  • Windows系統下Node.js的簡單入門教程
  • 零基礎搭建Node.js、Express、Ejs、Mongodb伺服器及應用開發入門
  • Java開發人員結合Node.js編程入門教程
  • Node.js入門教程:在windows和Linux上安裝配置Node.js圖文教程
  • node.js入門教程
  • node.js Web應用程式框架Express入門指南
  • node.js中的socket.io入門執行個體
  • node.js入門教程迷你書、node.js入門web應用開發完全樣本
  • 伺服器端的JavaScript指令碼 Node.js 使用入門

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.