Introduction to Node.js(1)
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
-
分享到:
相关推荐
Chapter 1, Welcome to the Node.js Platform, serves as an introduction to the world of Node.js application design by showing the patterns at the core of the platform itself. It covers the Node.js ...
This book is the ideal introduction for JavaScript developers who want to create scalable server side applications using Node.js and Koa.js. The book shows you how Koa can be used to start projects ...
Part 1 provides an introduction to Node.js, teaching the fundamental techniques needed to develop with it. Chapter 1 explains the characteristics of JavaScript and Node and steps through example code....
JavaScript Applications with Node.js, React, React Native and MongoDB: Design, code, test, deploy and manage in Amazon AWS By 作者: Eric Bush ISBN-10 书号: 0997196661 ISBN-13 书号: 9780997196665 出版...
本书《Professional Node.js: Building JavaScript Based Scalable Software》深入讲解了如何使用Node.js构建可扩展的软件,并将重点放在了基于JavaScript的开发上。全书分为几个主要部分,覆盖了Node.js的安装与...
A practical introduction to Node.js, an exciting server-side JavaScript web development stack Overview Learn about server-side JavaScript with Node.js and Node modules. Website development both with...
Serverless Applications with Node.js walks you through building serverless apps on AWS using JavaScript. Inside, you'll discover what Claudia.js brings to the table as you build and deploy a scalable ...
2. **Node.js模块作者**:对于希望将平台API封装成一套同步或异步API的Node.js模块作者而言,libuv同样是一个重要的工具。尽管这份文档不会深入讨论如何在Node.js环境中使用libuv,但它提供了一些基本的概念和技术,...
This handbook is a getting started guide to Node.js, the server-side JavaScript runtime environment. The Node.js Handbook follows the 80/20 rule: learn in 20% of the time the 80% of a topic. Node.js ...
**部分内容**:NodeWebDevelopment,A practical introduction to Node, the exciting new server-side JavaScript web development stack. 3. **技术栈组成**: - **核心模块**:Node.js 自带了一系列内置模块,...
Anode builds to an Android application package (.apk) that encapsulates the node.js runtime and can run node.js applications through an intent-based API. Status This work is at an early stage. All ...
Node.js简介 这是Node.js上LinuxFoundationX(edX)的类 第2章 固定服务器,模拟GET路由 文件夹的名称设置路由的路径前缀。 因此,如果我们使用fastify.get('/foo', …)设置GET /foo路由 在/confectionery/文件夹中...
"introduction-to-nodejs-mongodb-meteor-master"这个文件名暗示这是一个开源项目,可能包含有关Node.js、MongoDB和Meteor的教程、示例代码或者一个简单的应用。项目中的文件和目录会详细展示如何在实际开发中结合这...
- **灵活性**:不仅可以用于前端开发,也可以结合后端框架(如Node.js)进行全栈开发。 - **广泛的应用场景**:适用于各种类型的网页开发,从小型个人项目到大型企业级应用程序。 ### JavaScript如何工作 当浏览器...
1. Node.js入门(Node.js Introduction):Node.js是一个基于Chrome V8引擎的JavaScript运行环境,它允许开发者使用JavaScript来编写服务器端代码。Node.js的非阻塞I/O模型使其非常适合处理大量的并发连接,非常适合...