This article is about the 4 great advantages of node. js and the choice of node. js Four point reason, are the benefits of node. js, of course, there are certainly bad places, the article also describes the five shortcomings of
Notes from the node. JS Development Guide ByvoidChapter 1th Introduction to Node. jsnode. JS is a development platform that allows JavaScript to run on the server, making JavaScript a world-class citizen of the scripting language and serving PHP, Python, Perl, and Ruby on an
server end of websocket, to push messages to the front end of spring MVC Framework in java,
Use node. js to install the WebSocket Library:Npm install ws and then create the server:Var WebSocketServer = require ('ws '). server, wss = new WebSocketServer ({port: 8080}); wss. on ('connection', function (ws) {ws. on ('message', function (message) {console. log ('stored ed: % s', message) ;}); ws. send ('someth
write the class name and ID name after the label name. For example:
Div # content p. lead. center | Pandora_galen # side-bar.pull-right // no label name, the default is "div" span. contact. span4 a (href = "/contact" rel = "external nofollow" rel = "external nofollow") contact me
HTML for rendering output:
6. Text
Use the '|' symbol to output the original text.
Div | I started learning front-end two years ago. | in the meantime, I learned html, jQue
Section
Create a folder, such as myapp. After npm init is in it, the node_modules dependent folder will also be created.
Use npm install -- save to install the following dependencies:
1. express
2. mysql
3. body-parser (used to parse the post parameter)
Because express does not seem to have its own database encapsulation, it generally creates a new models folder and then writes the database logic. If you just want to perform a simple test, you can directly write it in app.
Details about the Async and Await functions in Node. js, node. jsasync
In this article, you will learn how to use the async function (async/await) in Node. js to simplify callback or Promise.
Asynchronous language structure already exists in other languages, such as c #'s as
subscript without using the array subscript to manipulate all the satisfied node objects.
The performance of getElementById is better compared to using document.queryselector, so using the latter can improve performance when selecting nodes is relatively straightforward (finding nodes faster).
2. Use comparison of jquery and native JS node objects//jque
);Console.log (' HEADERS: ' + json.stringfy (res.headers));Res.setencoding (' UTF8 ');Res.on (' Data ', function (chunk) {Console.log (' BODY: ' + chunk);});});Req.on (' Error ', function (e) {Console.log (' Problem with request: ' + e.message);});Write data to request bodyReq.write (' data\n ');Req.write (' data2\n ');Req.end ();Note: If you add more than 10 listeners to an event, you get a warning because the designer thinks that too many listeners
Detailed description of Node. js Streams file read and write operations, node. jsstreams
Node. js is inherently asynchronous and event-driven, and is very suitable for processing I/O-related tasks. If you are dealing with I/O-related operations in the application, you can us
A Simple Method for reading and writing Redis databases in Node. js applications, node. jsredis
Before starting this article, make sure that you have installed Redis, Node. js, and Node. js
connections, or to ip_hash ensure that the same IP request must be handled by the same node. JS process.Multiple node. JS processes can take full advantage of the processing power of multicore CPUs and have a strong ability to expand.Event LoopsThere is an event loop in node
Introduction to the Node. js lightweight Web framework Express4.x User Guide, node. jsexpress4.x
Express is a lightweight Web framework that is simple and flexible
It is also the most popular Nodejs-based Web framework.
With this feature, we can quickly build a complete website (express)
Express is now in version 4.x, which is updated quickly and is not compatibl
, after the site is opened, the following error occurs:Copy codeThe Code is as follows:The request Filtering module is configured to reject the path in the URL containing the hiddenSegment section.The bin directory in ASP. NET is a special directory that cannot be accessed. Rewrite the request to bin/www, which hits this rule. So, just change the directory name. For example, change bin to launch (it turns out that this is not a good practice, and we w
), offsetparent takes the nearest parent element.IE7 below, if the current element is not positioned by default is body, if there is a location it is HTMLIE7 below, if layout is triggered by a parent of the current element, then offsetparent will be directed to the parent node that triggered the layout attributeElement. Offsetleft[top], Offsetwidth[top]:Detailed Explanation:Http://www.cnblogs.com/jscode/archive/2012/09/03/2669299.htmlGets the distance
.-MysqlDB. js is used to provide user. js with the tool class for linking the database and the class for actually operating the database.-User. js is used to provide the Implementation Layer with an addition, deletion, modification, and query method for users, which is equiv
= require ('child _ Process '). spawn; // Child will use parent's stdios // use the stdios spawn ('prg', [], {stdio: 'error'}) of the parent process '}); // generate a shared process. stderr sub-process // Spawn child sharing only stderr spawn ('prg', [], {stdio: ['pipe', 'pipe', process. stderr]}); // Open an extra fd = 4, to interact with programs presenting a // startd-style interface. spawn ('prg', [], {stdio: ['pipe', null, 'pipe']});
Note: When
, index) {return new Promise (function (resolve, reject) {fs. readFile (file, 'utf-8', function (err, str) {if (! Err) {resolve (str)} else {reject (err) }}) ;}); return Promise. all (readFilsePromiseList );}). then (function (fileStrArray) {console. log ('after reading the so-called file: '+ fileStrArray );});
This Code indeed shows the elegance of nodejs development.
So where is the problem?
Currently, the elegant language still relies on the operating system. That is to say, the system restri
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.