Introduction to Node.js(1)
Introduction to Node.js(1)
- by Poechant (blog.csdn.net/poechant)
1 Hello World
$ sudo port install nodejs
$ echo "console.log(\"Hello World\");" > helloword.js
$ node helloworld.js
2 A simple TCP server
Create a file named “simple_tcp_server.js”
require("net").createServer(function(socket) {
socket.write('Echo server\r\n');
socket.pipe(socket);
}).listen(8765, "127.0.0.1");
Run your server:
$ node simple_tcp_server.js
3 A simple HTTP server
Create a file named “simple_http_server.js”
require("http").createServer(function(request, response) {
console.log("Hello World");
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World\n");
response.end();
}).listen(8765, "127.0.0.1");
-
轉載請註明來自柳大的CSDN部落格:blog.csdn.net/poechant
-
相關文章
- 1 Introduction to the Multitenant ArchitectureNaN
- cs231n lecture1 introduction
- Introduction to A*
- [Java] Introduction to Java Programming 筆記: Chapter 1. 概念Java筆記APT
- MIT6.S081 - Lecture1: Introduction and ExamplesMIT
- Introduction to Vetors
- RL Introduction
- nodejs introductionNodeJS
- [CS131] Lecture 1 Course Introduction課程介紹
- self-introduction
- HTML 01 - IntroductionHTML
- TLS 1.3 IntroductionTLS
- A gentle introduction to multithreadingthread
- FFmpeg Filtering IntroductionFilter
- Introduction to Systems Programming .
- Aizu Online Judge Introduction to Programming I C語言實現 ITP1 Topic # 1AIC語言
- Machine Learning-IntroductionMac
- HMAC: Introduction, History, and ApplicationsMacAPP
- An introduction to SAP Business Workflow
- EESA01 Introduction to Environmental
- CSCI1120 Introduction to Computing
- CCIT4020 Introduction to Computer
- Node.js學習筆記1Node.js筆記
- <node.js學習筆記(1)>Node.js筆記
- Neural Radiance Field (NeRF): A Gentle Introduction
- CCIT4020 Introduction to Computer Programming
- CS439: Introduction to Data Science
- MA2552 Introduction to Computing (DLI)
- CPSC 219: Introduction to Computer Science II
- COMP42215 Introduction to Computer Science
- [Node.js月刊]2018年第1期Node.js
- INT2067 Introduction to Programming and Problem Solving
- Introduction to Keras for Engineers--官網學習Keras
- Oracle 19c Concepts(01):Introduction to Oracle DatabaseOracleDatabase
- 強化學習第二版(翻譯)第一章 導論(前言)Chapter 1 Introduction強化學習APT
- 【筆記】【THM】Introduction to Cryptography(密碼學簡介)筆記密碼學
- CRS Resource Introduction In Oracle 19c RAC-20220125Oracle
- 讓Node.js和C++一起搞基 —— 1Node.jsC++
- 2018.09.22 上海大學技術分享 – An Introduction To Go Programming LanguageGo