To serve static files such as images, CSS files, and JavaScript files, we can use built-in middleware function in Express. i.e. express.static
we simply need to pass the name of the folder where we have our static files, to the express.static middleware to start serving the files directly. For example, if you keep your images, CSS, and JavaScript files in a folder named public, we can use below code −
app.use(express.static('public'));
Now, you can load the files that are in the public directory:
http://localhost:3000/images/hello.jpg
http://localhost:3000/css/hello.css
http://localhost:3000/js/hello.js
http://localhost:3000/images/hello.png
http://localhost:3000/hello.html
Express...
Node js with express framework

What is express
Express is node js web application framework which provide set of feature to develop web and mobile applications. It provides following features.
Robust routing
Focus on high performance
Super-high test coverage
HTTP helpers (redirection, caching, etc)
View system supporting 14+ template engines
Content negotiation
Executable for generating applications quickly
How to install expressjs
$ npm install --save express
The...
What is Node package manager
After my first tutorials which is How to create server in node js i want to explain what is node package manager. Because after this tutorials we gonna look in how's node module works. So let's start with what is node package manager.
Node package manager is online repositories for node.js packages/modules. To install node package and do version management we have to use commands.
To check current NPM version on your computer type below command
$ npm --version
If you running old version than you can update easily by running...
How to create server in node js

Hello guy's After working 3 years in node i finally decided to write tutorials on node. When i started node js i also faced so many challenge so i know how to overcome with this challenges. so let's start with first node js tutorial.
Today we will start first thing which i did in node js. Node create its own webserver so we will learn today how to create server in node js as your first application in node js.
Before we start i hope you...
Powered by Blogger.