middleware officially. We recommend that you use "multiparty" directly because it is troublesome to handle errors.
Next we will use "multiparty" to implement a version.
1. Use express (version 4.11.x) to create a project and use the default jade as the template engine.
2. In the project directory, install necessary components through npm install multiparty.
3. Modify views/index. jade to make a simple form for file upload.
Extends layout block conte
node. js file read/write, convert sheet Atlas data to keel animation Atlas data
var fs = require("fs")
var readline = require("readline");
var rl = readline.createInterface({
input:process.stdin,
output:process.stdout
});
var path = undefined;
var dbName = undefined;
rl.question("请输入文件名",function(answer){
path
These days, I have contacted node. js + express and found that no matter whether jade or ejs template system is used, a layout. (Jade | ejs) file will be automatically created. It is also used in a file name convention, instead of specifying layout in the code. However, in actual projects, multiple layout files may be
The file describing the package is a Package.json file.One such file, the information inside is quite big. We can give up manually. In order to practiced hand we have a command line to build such a package;After completing the information for the Name,varsion....license entry, you will be prompted with a message.Above is the information we fill in, we enter Yes below, the completion of the Package.json pack
/*** Gets the sum of all the file sizes in the specified directory in bytes* @param dir* @param callback*/function Getdirsize (dir,callback) {var size = 0;Fs.stat (Dir,function (err,stats) {if (ERR) return callback (ERR);//If an error occursif (Stats.isfile ()) return callback (null,stats.size);//If the fileFs.readdir (Dir,function (err,files) {//If it is a directoryif (ERR) return callback (ERR);//If traversing directory errorif (files.length==0) ret
The third chapter of the original tutorial Https://github.com/nswbmw/N-blog/wiki/_pagesThere are three ways to upload files now:Use Express's own file upload feature, no database involvedUse formidable external module, no database involvedUploading to MongoDB, involving the databaseHere you use the first, the user will file, stored in: blog/public/images/folder.Blog/views/header.ejs in Index.js Add code:Fs=
. conf file and add the following
Nameserver 8.8.8.8Nameserver 8.8.4.4Save and close.
Step end. Test whether node. js can be run
Now that you have completed the setup, but you don't know if it can run correctly, let's write an example file to test it.
Create example. js
This article mainly introduces a simple node. js server example. This article implements a simple helloworld example and shows how to run this server, for more information, see the following example: hello world.
It seems that the first section of each language tutorial will talk about this, and we are no exception.
First, create a project directory, which can be defined by yourself. In this case, the d
This article analyzes and explains node through several examples. the use of require in js is very detailed. Here we recommend that you provide a very clear description in the code comments. Here we will not talk nonsense about it. We will provide the Code directly:
The Code is as follows:
/* In node, you can use the require () function to load modules.* The r
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 )
suffix can be omitted; start with "/" with an absolute path to load, ". /"starts ".. /"starts ". /"indicates files under the same directory,
The file suffix mentioned above can be omitted. The priority js file to be loaded by Nodejs is> json File> node
completed the setup, but you don't know if it can run correctly, let's write an example file to test it.
Create example. js in the C: cygwin directory
Input
Var http = require ('http ');
Http. createServer (function (request, response ){
Response. writeHead (200, {'content-type': 'text/html '});
Response. end ('Hello World');
}). Listen (8888 );
Console. log ('s
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.