Express.js

Configurare noua (How To)

Situatie

Express.js is a small framework that works on top of Node.js web server functionality to simplify its APIs and add helpful new features. It makes it easier to organize your application’s functionality with middleware and routing. It adds helpful utilities to Node.js HTTP objects and facilitates the rendering of dynamic HTTP objects.

Solutie

Pasi de urmat

We can install it with npm. Make sure that you have Node.js and npm installed.

Creating a directory for our project and make that our working directory.

$ mkdir gfg
$ cd gfg

Using npm init command to create a package.json file for our project.

$ npm init

This command describes all the dependencies of our project. The file will be updated when adding further Installing Express

Now in your gfg(name of your folder) folder type the following command line:

$ npm install express --save

Write the following code in app.js.

var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send("Welocme to GeeksforGeeks!");
});
app.listen(5000);

Step to run the application: Start the app by typing following command.

node app.js

Tip solutie

Permanent

Voteaza

(2 din 11 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?