Home » » Node.Js Tutorial For Beginners Twenty - Introduction To Express.Js

Node.Js Tutorial For Beginners Twenty - Introduction To Express.Js




npm init command

$ npm init This utility volition walk you lot through creating a package.json file. Press ^C at whatsoever fourth dimension to quit. name: (express_test) demo version: (1.0.0) description: Demo of package.json entry point: (index.js) test command: git repository: keywords: author:  license: (ISC) 

install limited via npm

 npm install limited --save 


index.js

var limited = require('express');  var app = express(); // GET // POST // PUT // DELETE  app.get('/', function(req, rep) {     rep.send('this is dwelling page'); })  app.get('/about', function(req, rep) {     rep.send('this is close page'); })  app.get('/contect', function(req, rep) {     rep.send('this is contect page'); })  app.listen(3000, function() {     console.log('our server is alive on posrt 3000'); }) 

package.json

{   "name": "express_test",   "version": "1.0.0",   "description": "",   "main": "index.js",   "scripts": {     "test": "echo \"Error: no exam specified\" && popular off 1"   },   "author": "",   "license": "ISC",   "dependencies": {     "express": "^4.14.1"   } } 

0 comments:

Post a Comment

Search

Blog Archive