`
Poechant
  • 浏览: 229429 次
博客专栏
Bebe66e7-3a30-3fc9-aeea-cfa3b474b591
Nginx高性能Web服务...
浏览量:24307
5738817b-23a1-3a32-86de-632d7da73b1e
Cumulus实时媒体服务...
浏览量:22094
社区版块
存档分类
最新评论

Introduction to Node.js(1)

 
阅读更多

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

-

分享到:
评论

相关推荐

    Node.js Design Patterns Second Edition[July 2016]

    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 ...

    Server Side development with Node.js and Koa.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 ...

    Node.js In Action 2nd Edition

    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

    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

    本书《Professional Node.js: Building JavaScript Based Scalable Software》深入讲解了如何使用Node.js构建可扩展的软件,并将重点放在了基于JavaScript的开发上。全书分为几个主要部分,覆盖了Node.js的安装与...

    [Node] Node 网络应用开发 第2版 (英文版)

    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

    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 ...

    An Introduction to libuv.pdf

    2. **Node.js模块作者**:对于希望将平台API封装成一套同步或异步API的Node.js模块作者而言,libuv同样是一个重要的工具。尽管这份文档不会深入讨论如何在Node.js环境中使用libuv,但它提供了一些基本的概念和技术,...

    The Node.js Handbook 1st Edition.Pdf

    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 ...

    Node Web Development.pdf

    **部分内容**:NodeWebDevelopment,A practical introduction to Node, the exciting new server-side JavaScript web development stack. 3. **技术栈组成**: - **核心模块**:Node.js 自带了一系列内置模块,...

    Android代码-anode

    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 ...

    Introduction-to-Node.js:EdX培训课程将于2021年4月8日到期

    Node.js简介 这是Node.js上LinuxFoundationX(edX)的类 第2章 固定服务器,模拟GET路由 文件夹的名称设置路由的路径前缀。 因此,如果我们使用fastify.get('/foo', …)设置GET /foo路由 在/confectionery/文件夹中...

    introduction-to-nodejs-mongodb-meteor:Node.js,MongoDB和Meteor简介

    "introduction-to-nodejs-mongodb-meteor-master"这个文件名暗示这是一个开源项目,可能包含有关Node.js、MongoDB和Meteor的教程、示例代码或者一个简单的应用。项目中的文件和目录会详细展示如何在实际开发中结合这...

    Introduction to JavaScript Part 1

    - **灵活性**:不仅可以用于前端开发,也可以结合后端框架(如Node.js)进行全栈开发。 - **广泛的应用场景**:适用于各种类型的网页开发,从小型个人项目到大型企业级应用程序。 ### JavaScript如何工作 当浏览器...

    Full Stack JS Dev with MEAN

    1. Node.js入门(Node.js Introduction):Node.js是一个基于Chrome V8引擎的JavaScript运行环境,它允许开发者使用JavaScript来编写服务器端代码。Node.js的非阻塞I/O模型使其非常适合处理大量的并发连接,非常适合...

Global site tag (gtag.js) - Google Analytics