AngularJS and Node.js are two of the most popular leading JavaScript Application frameworks, which are used for building interactive and feature rich cross-platform web applications.
Both the frameworks use techniques like AJAX, DHTML, DOM scripting and much more.
The following infographic explains their differences in detailed points.
From: https://blog.sagipl.com/node-js-vs-angular-js/
Learn the powerful enterprise adaptable database:
Getting Started With ADABAS & Natural
Friday, March 2, 2018
NodeJS Express Framework
Introduction
Express is a minimal and flexible Node.js web application framework that provides a robust set of features to develop web and mobile applications. It facilitates the rapid development of Node based Web applications.
Features:
- Allows to set up middlewares to respond to HTTP Requests.
- Defines a routing table which is used to perform different actions based on HTTP Method and URL.
- Allows to dynamically render HTML Pages based on passing arguments to templates.
How To Install Express?
- Run NodeJS command to install Express
- e.g. sudo npm install express --save
- The above command saves the installation locally in the node_modules directory and creates a directory express inside node_modules.
- Run NodeJS command to install important modules
- e.g. sudo npm install body-parser --save
- This is a node.js middleware for handling JSON, Raw, Text and URL encoded form data.
- e.g. sudo npm install cookie-parser --save
- Parse Cookie header and populate req.cookies with an object keyed by the cookie names.
- e.g. sudo npm install multer --save
- This is a node.js middleware for handling multipart/form-data.
Simple Demo
- Go to your target http root folder.
- Prepare server.js script file
- var express = require('express');
- var app = express();
- app.get('/', function (req, res) {
- res.send('Hello World');
- })
- var server = app.listen(8081, function () {
- var host = server.address().address
- var port = server.address().port
- console.log("Example app listening at http://%s:%s", host, port)
- })
- Type NodeJS command to start the server
- e.g. sudo node server.js
- Browse the web page
- e.g. http://localhost:8081/
- This app responds with Hello World! for requests to the homepage. For every other path, it will respond with a 404 Not Found.
- To stop the server, press (in the console window):
- CTRL-C
Originally from: https://www.tutorialspoint.com/nodejs/nodejs_express_framework.htm
NodeJS Simple HTTP Server (Local Web Server)
- Install NodeJS
- Install http-server package
- e.g. sudo npm install -g http-server
- Go to your target http root folder
- e.g cd\web\root
- Type command to run http-server
- e.g. http-server
- To stop the server type:
- CTRL-C
Subscribe to:
Posts (Atom)