Client-clients, commonly referred to as browsers, can request data from the server via the HTTP protocol.
Server -a server-side, generally referred to as the Web servers, can receive client requests and send response data to the client.
Business-service layer, which handles applications through Web servers, such as interacting with databases, logical operations, calling external programs, and so on.
given request, ithe middleware would not run. The function'll has access to Koa ' s context viathis
useOriginalUrlIt should are true or false , default is true . If False, would path match against ctx.url instead of ctx.originalUrl .
ExamplesRequire authentication for every request skip the path is index.html.App.Use(Requiresauth(). Skip ( {path:[/index.html ' , / ' ] }) ) Avoid a fstat for request to routes doesnt end with a given extension.app. Use(static. Skip(function () {
': ' text/html '}); //Response File ContentsResponse.Write (Data.tostring ()); } //Send response DataResponse.End (); }); }). Listen (8081);//the console will output the following informationConsole.log (' Server running at http://127.0.0.1:8081/');Create a index.htmlHTML>Head>title>Sample Pagetitle>Head>Body>Hello world!Body>HTML>After entering http://127.0.0.1:8081/index.htmlUse Node to create a WEB
2.1 Installing ExpressIf a package is a dependency of a project, then we need to install the package in local mode in the project directory, and if you want to invoke the command in this package from the command line, you need to install it in global mode. Express provides a tool for quickly building projects on the command line, so we use global installation:$ NPM Install-g Express 2.2 Establishment of the projectExpress when initializing a project, you need to specify a template engine that e
Nodejs is actually a JavaScript execution environment.To create a new file Server.js, enter the following code:var http = require (' http 'var server = Http.createserver (function(req, res) { Res.writehead ($, {' Content-type ': ' Text/plain '}); Res.end (' Hello world\n ');}); Server.listen (1337, ' 127.0.0.1 '); Console.log (' Server running at http://127.0.0.1:1337 ');The console goes to the directory where the file was changed and executes the command:
https://hacks.mozilla.org/2015/04/es6-in-depth-an-introduction/What falls under the scope of ECMAScript?The JavaScript programming language is standardized by ECMA (a standards body like the website) under the name ECMAScript. Among other things, ECMAScript defines:
Language syntax–parsing Rules, keywords, statements, declarations, operators, etc.
Types–boolean, number, String, object, etc.
Prototypes and inheritance
The standard library of built-in objects and functions– JS
Using JavaScript to access cross-domain pages on the front-end often uses Ajax, and the backend node. JS is much easier to crawl web information.Here is one of the simplest examples of crawling my blog home page information and displaying the homepage blog title.1 varHTTP = require (' http ')2 varCheerio = require (' Cheerio '))3 4 varurl = ' http://www.cnblogs.c
[Web API series] 1.3-practice: use ASP. NET Web API and Angular. js to create a single page application (on)Preface
In traditional web applications, the client (browser) initiates communication with the server through the request page. The server then processes the request a
Open service:The code is as follows:varHTTP = require ('http'); Http.createserver (function (request, response) {//Send HTTP Header//HTTP Status value: 200:ok//content Type: Text/plainResponse.writehead ( $, {'Content-type':'Text/plain'}); //Send response data "Hello World"Response.End ('Hello world\n');}). Listen (8888);//The terminal prints the following informationConsole.log ('Server running at http://127.0.0.1:8888/');node.
Getting started with Node. js development-notepad ++ for Node. js and node. jsnotepad
For Node. js development, IDE,WebstormIt is the best option, but it is charged (free for 30 days )
This article mainly introduces several important knowledge points of node. js: The Role of node. js, callback, synchronous and asynchronous code, event loop 1, and the role of node. js,
The meaning of I/O. Move the mouse to see t
JavaScript on the web. Firefox has an engine called SpiderMonkey, Safari has javascriptcore,chrome V8
node. JS is the V8 engine with the ability to manipulate I/O and the network library, so you can use JavaScript to create shell scripts and background services outside the browser or to run on hardware
JavaScript is a
more about JavaScript, it's not too much to discuss here. But it's really a key advantage of using Node in the development process. as Wikipedia says: "Node. js is a wrapper shell for the Google V8 engine, the LIBUV platform abstraction layer, and the core library that the subject uses Javscript to write. "Beyond that, it's worth noting that the goal of the auth
-v" to view the version of the Node package management tool you have installed. have you finished it? OK. Let's get started !!
Open the Notepad program and we will build our first Node. js applications. copy the following code to the Notepad program and use any file name, for example, "example. js "and save it to the f
number of connections exist.
Nginx, a well-known server, also abandons the multi-thread approach and adopts the same event-driven approach as Node. Today, Nginx is a great replacement for Apache. Nginx is written in pure C mode with high performance. However, Nginx is only suitable for Web servers and is used for reverse proxy or Server Load balancer. Node can b
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.