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
The installation process will not be mentioned. If it succeeds, you can use the node command. Node. js debugging is very convenient. Each background language has a command to output a pragmatic command to the console Group of the Black hacker. Node.
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
Recently, I decided to refresh node. js and use it to merge JS files. Because I forgot about it, let's see if I can output a page first. Below are some of my notes, saving you the trouble to forget the installation process. If it succeeds, you can use the node command. Node.
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
Mode and will package js in the memory, if you change the file, it will repackage the app. use (webpackDevMiddleware (webpack (WebpackConfig), {publicPath: '/_ build _/', stats: {colors: true}); // general configuration item app. set ('view', _ dirname + '/view'); app. set ('view engine ', 'ejs'); app. set ('view options', {layout: false}); app. use (bodyParser. urlencoded ({extended: true}); app. use (bodyParser. json (); app. use (methodOverride ()
the consumer, and the called consumer is idle.
There is a message queue in the Javascript runtime, and the message is associated with a callback function. When an event is triggered, if the event has a corresponding callback function, the message is added to the message queue.
Let's look back at what the event loop is. After the code starts to be executed, the function is pushed into the calling pipeline. In this example, the request is pushed into the calling pipeline, this function will make
This article mainly introduces node. fs. readSync method usage instructions. This article introduces fs. readSync method description, syntax, receive parameters, use instances, and implement Source Code. For more information, see
Method description:
Synchronous version of fs. read ().
Method returns a bytesRead (number of bytes read)
Syntax:
The Code is as follows:
Fs. readSync (fd, buffer, offset, length, position)
Because this method belongs to
be good first, and the method is very simple. Just execute the following command:
npm install forever -g
After the installation is complete, test it with a simple Node program:
forever start test.jsforever stop test.jsforever restart test.js
If no error is prompted, it indicates that forever can be used. That is to say, the basic conditions for using forever to start a Node project in the background ar
the exports and module. exports
When a node executes a file, it generates an exports and module object for the file,
The module has an exports attribute. For example, the relationships between them all point to a {} memory area.
exports = module.exports = {};
Let's take a look at the code.
// Utils. jslet a = 100; console. log (module. exports); // The output r
signature authentication for our students.
Create an express framework
We have installed the express module in the previous course and created a file named app. js in the environment on the right. Now we will complete the express framework in this file. The following code:
Var express = require ("express"); var path = require ('path'); var app = express (); server = require ('http '). server (app); app. set ('view' ,__ dirname); // sets the view app
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 describes how to use the console.info method in node. js. This article describes the console.info method, syntax, receiving parameters, use instances, and implementation source code. For more information, see
Method description:
This method is the same as console. log. From the source code, it directly
Node. js loop traps and node. js loop traps
The asynchronous mechanism of Node. js is implemented by events and callback functions. It may feel like a violation of the Conventions at the beginning, but it will be very easy to get
This article mainly introduces Node. the general module Encapsulation Method in js. For the encapsulation method, see Underscore. js implementation. For more information, see Node. the module loading and execution are encapsulated in js, so that the variables in the module F
request to the source to obtain the data function downloadRSSFeed (feedUrl) {request ({uri: feedUrl}, function (err, res, body) {if (err) {return next (err);} if (res. statusCode! = 200) {return next (new Error ('Abnormal response status Code');} next (null, body );});} // parse the function parseRSSFeed (rss) {var handler = new htmlparser. rssHandler (); var parser = new htmlparser. parser (handler); parser. parseComplete (rss); if (! Handler. dom. items. length) {return next (new Error ('no R
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
The installation process will not be mentioned. If it succeeds, you can use the node command. Node. js debugging is very convenient. Each background language has a command to output a pragmatic command to the console Group of the Black hacker. Node.
,/a/B/aa.txt => aa.txt. At first, I used to intercept the string, but the operating system may be different. In mac, '/'. window is '\', which is also a problem discovered after the deployment is complete. Later, we found that path. basename was directly replaced (if the document was read less, it would suffer ). Adding 1 point to your liking for node. js. :)
3. redis cache frequently queries and rarely cha
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.