Express – Node.js web application framework – Get started

In this lesson we will study how to install Express web application framework on Node.js and study the basic routing

How to install the Express

You can have the following code in server.js

Now you can start the server

Now you can test url http://localhost:3000 in your browser

Really simple to install and run your first piece of code

 
Routing made easy with Express
By default, express gives you the routing functionality

This is very basic router example for a home page. It responds with “Hello World” message

This is router with respond to POST request

This is a simple example for form submission, see how routes are working here we have GET and POST here with http://localhost:3000/user

You can define router for named URL segment like this

Leave a Reply

Your email address will not be published. Required fields are marked *