compiles them into html and finally delivers them to the client (browser). Here I am using ejs, and its syntax is similar to html.
3. To run the server, enter node app in the command line. If webstorm is used, you can directly debug app. js. webstorm supports node. js very
This article mainly introduces node. the implementation principle of RPC (Remote process call) in js is introduced. This article is based on a simple RPC library nodejslight_rpc implementation. If you need a friend, refer to RPC (Remote process call ), that is, you can call the Program Method on the remote host locally and see a simple nodejs implementation to learn the RPC principle well: nodejs light_rpc
Node. js Web application framework, which is often used when building HTTP servers. Therefore, it is explained directly using Socket. IO and express as examples.
Copy codeThe Code is as follows:Var express = require ('express '), App = express (), Server = require ('http'). createServer (app), Io = require ('socket. io '). listen (server );Server. listen (3001 );
If you do not use express, see socket. io/#
Write at the beginning: In fact, I was thinking about whether to write this thing, because this thing is not difficult, but why there are so many people ask, they are not asking how to use the console, but do not know what the console can do, they also know that there are console.log and other things, But they don't know why they use such a long string instead of alert output information. Alert enough in th
Module stability: 5-lockednode has a simple module loading mechanism. in node, files and modules are one-to-one. for example, foo. javascript loads the circle in the same folder. js module. foo. js content: [javascript] lt; SPANstyle quot; FONT -...
Module)
Stability: 5-locked
Node has a simple module loading mechani
2 methods for connecting node. js to MongoDB database tutorial, node. jsmongodb
Preface
The MongoDB Node. js driver is officially supported by the native node. js driver. It is the best
Node. js BASICS (10) use the net module and Readline module to implement Socket communication, and node. jsreadline
The socket communication of Node. js is very similar to that of C ++ and Java. Those who have learned the socket communication of these two languages can quic
, these exceptions should be recorded in the log, and the exception will never happen again.Use node to guard nodeThe Node-forever provides the function of guarding and log logging.Very easy to install[sudo] npm install foreverIt's easy to use.$ Forever Start Simple-server.js$ Forever List[0] simple-server.js [24597, 24596]You can also read the logForever-o out.log-e Err.log My-script.jsDaemon
This article mainly introduces node. socket. io broadcast messages. For more information, see socket. the io () server has a sockets attribute. The attribute value is all socket objects connected to the client. you can use the send method or emit method of this object to broadcast messages to all clients.
Io. sockets. send ("user commected );
Io. socket. emit ("login", names );
Case
Server. js code:
The
This article mainly introduces node. url in js. description of the parse method. This article describes the url. parse method description, syntax, receive parameters, use instances, and implement Source Code. For more information, see
Method description:
Converts a URL string to an object and returns it.
Syntax:
The Code is as follows:
Url. parse (urlStr, [parseQueryString], [slashesDenoteHost])
Receivi
This article mainly introduces node. url in js. the format method is described in this document. format method description, syntax, receive parameters, use instances, and implement Source Code. For more information, see
Method description:
Convert a parsed URL object into a formatted URL string.
Syntax:
The Code is as follows:
Url. format (urlObj)
Receiving parameters:
UrlObj indicates a URL object and
Node. js uses cluster to implement multi-process, node. jscluster
First, solemnly declare:
NodeJS is a single thread! Asynchronous! Non-blocking language!NodeJS is a single thread! Asynchronous! Non-blocking language!NodeJS is a single thread! Asynchronous! Non-blocking language!
The important thing is said three times. Because
This article mainly introduces node. socket. js. i/O advanced usage skills. This article describes the configuration, room, event, authorization, and other content. For more information, see Socket in the previous blog. IO, I briefly introduced Socket. i/O basic usage and a simple chat room DEMO is created. This article will continue to explore the advanced usage of Socket. IO Based on the introduction. Thi
\":\"test11\"}}" http://localhost:3000/leaderboards
View the TOP 10 commands as follows:
curl http://localhost:3000/leaderboards
In standard REST definitions, POST and PUT have different meanings. GET can distinguish a single resource or a list of resources. We have simplified this application. Both ADD and UPDATE use POST in a unified manner, and there is no distinction between a single resource and a list. The TOP 10 Data is directly returned.
Some preparations
Install
'test'. 'proc _ simple' $Create procedure proc_simple (IN uid INT (10), OUT uName VARCHAR (2), OUT totalCount INT)BEGIN
DECLARE str_name VARCHAR (20 );
SET @ str_name = '';SET totalCount = 0;Select count (1), userName INTO totalCount, @ str_name FROM user_info WHERE userId = uid;SET uName = @ str_name;SELECT uName, totalCount;END $DELIMITER;
4. Write a program for calling (assuming that the file named SQL. js is saved );
Copy codeThe Code is as fol
(), Warning Console.warn (), Error message Console.error ().For example, insert the following four lines in the Web script:
Console.info ("This is Info");
Console.debug ("This is Debug");
Console.warn ("This is warn");
Console.error ("This is Error");
When loaded, the console displays the following content.Can see, different nature of the information in front of the different icon
#events (take a closer look at events, there may be other parts you want to use)But just in the console output, want to display the progress bar at the front end is not possible (not to study, think of other ways should also be able) 4. FileName want to name UUID does not repeat, what to do in Nodejs?You can use Node-uuid to invoke simple Https://github.com/broofa/node
Simple steps to build the Node. js development environment in Linux, linuxnode. js
1. Install node. js in Linux
Ubuntu:
sudo apt-get install nodejs npm
Centos:
yum install nodejs npm
For more detailed installation see: https://github.com/joyent/
can be found in the command line environment. The latter installs the third-party package in node_modules under the command execution directory as a dependency for a project, without exporting it to the global environment.
3 node Quick Start
3.1 run Node
The basic method for running a node application is to first write a JS
Node. js exports, module. exports, and ES6 export, export default in-depth explanation, node. jses6
Preface
Recently, it is rare to have time. I decided to learn node programming again in a standardized manner. However, the introduction module I see uses the require method, and I think of our ES6 various export and exp
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.