This article describes how to create a web calculator using node. js + express. For more information, see
Environment:
Host: WIN10
Express installation:
1. install express-generator
Enter the following command:
npm install -g express-generator
2. install express
Enter the following command:
npm install -g express
3. verify whether the installation is successful
Enter the command: express-V
View help: e
Node. js removes BOM headers in batches and node. js removes bom
My colleagues wrote a tool, but there is a bug that after the file is replaced, the format of the original file is changed to utf8 BOM. XML with BOM may not be readable on Mac, therefore, you need to write a tool for processing.
In fact, the idea is rela
Node. js static server implementation method, node. js static Server
When you enter a url, the url may correspond to a resource (File) on the server or a directory. The So server analyzes the url and does different things for different situations. If the url corresponds to a file, the server returns the file. If the ur
This article mainly introduces node. use socket in js. io method. For more information, see use socket. use io to create a socket. i/O server. however, this server depends on a created http server.
After the http server is running, use the listen method to append a socket. io server to the http server.
The Code is as follows:
Var sio = require ("scoket. io ");Var socket = sio. listen (server );
Socket i
This article mainly introduces node. js mongodb Operations Learning summary, this article provides mongodb to create a database, insert data, connect to the mongodb database and query data and other code instances, friends can refer to the next, preparation
1. Create a table to be read in mongodb
Create a database named Test
The Code is as follows:
Use extension test;
Insert data to the user table
The C
Node. js public platform development tutorial, node. js public
How can nodejs be used to develop public platforms?
Let's not talk about anything more. First, let's briefly introduce the basic principles of the public platform.
The server is equivalent to a forwarding server. A terminal (such as a mobile phone or tablet
Nodejs code snippets worth collecting. You can add them to your favorites and use them in subsequent work, if you are interested, you can refer to the following code snippets worth collecting for your reference:
1. For details about node. js static resource compression and caching, refer to: node. js creates a static
Create simple chat rooms for Node. js and simple chat rooms for node. js
I read about TCP and wrote a NET-based chat room.
Var net = require ('net'); var count = 0, users ={}; var server = net. createServer (function (conn) {console. log ('connection'); conn. write ("\ r \
This article mainly introduces the implementation of multi-process by child_process in Node. js. For more information, see
The code is as follows:
Var http = require ('http ');Function fib (n ){If (n Return 1;} Else {Return fib (n-2) + fib (n-1 );}}Var server = http. createServer (function (req, res ){Var num = parseInt (req. url. substring (1), 10 );Res. writeHead (200 );Res. end (fib (num) + "\ n ");});
This article mainly introduces the node. js game sharing that allows multiple users to move their mouse online at the same time. This article provides the server and client code and running methods. For more information, see the recent project requirements, so I studied the websocket Implementation of nodejs, socket. io, which is a widely used framework of nodejs background applications websocket.
Preparat
Simple implementation of node. js Image Upload and node. js Image Upload
The examples in this article share the code for uploading node. js images for your reference. The details are as follows:
1.
Command line arguments is often used to modify the behavior of a application or specify needed parameters for operation. In this lesson, you'll learn how to access the command line arguments passed to your node. JS application as well as dif Ferent strategies for evaluating and accessing them.To catch what arguement user passed on from command line, we can use 'process.argv '.If We log out:// Server.js Cons
= function (object ){Var util = require ('til ');Process. stdout. write (util. inspect (object) + '\ n ');}Var time = function (label ){Times [label] = Date. now ();}Var timeEnd = function (label ){Var duration = Date. now ()-times [label];Exports. log ('undefined: nanm', label, duration );}Var trace = function (label ){// TODO probably can to do this better with V8's debug object once that is// Exposed.Var err = new Error;Err. name = 'track ';Err. m
instance is obtained, you can use net. Socket to do whatever you want. I listened to the data event to receive the data played by the server, and listened to the close event to exit the process. For specific API of net. Socket, refer to https://nodejs.org/api/net.html#net_class_net_socket.Running example
There is a saying in the comments that the time is too late. Well, you can run it. Run "node echoServer. js
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 icons, and each message has a hyperlink behind, click to jump to the corresponding line
(), 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
(), 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
module ):
The Code is as follows:
Npm install supervisor-g
Assume that the main portal of your Node. js program is app. js, you only need to execute the following command to start monitoring file changes.
The Code is as follows:
Supervisor app. js
The Supervisor also supports multiple parameters, as shown below:
Basic tutorial on how to use the Request module to process HTTP requests in Node. js, node. jsrequest
Here we will introduce a Node. js module -- request. With this module, http requests become super simple.
The Request is simple and supports both https and redirection.
Va
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.