DEV Community

Cover image for Web Applications with Express.js (Beginners)
Collins Mbathi
Collins Mbathi

Posted on • Updated on

Web Applications with Express.js (Beginners)

Introduction

Node.js is a runtime environment used for server-side JavaScript. Express.js is a web framework used for server-side JavaScript. It is built on top of Node.js.

In this course, we will be building a simple CRUD web application using Express.js. CRUD stands for Create, Read, Update, Delete.

This course is for beginners. No prior knowledge of Node.js or Express.js is required.

In the following section, we will look at some of the prerequisites for this tutorial.

Prerequisites

The following are required to complete this tutorial:

  • Node.js installed on your system.
  • Sound knowledge of JavaScript and Nodejs.

Getting Started

You must first create a directory, navigate to it in your shell, and then install Express with npm by running npm install express —save.

Make a file called index.js and add the following code to it, which will create an Express server and add one endpoint to it with the app.get method:

const express = require('express');
const app = express();
app.get('/', (request, response) => {
 response.send('hello World');
});
app.listen(5000, 'localhost');


Enter fullscreen mode Exit fullscreen mode

Use the following command in your shell to run your command script:

node app.js
Enter fullscreen mode Exit fullscreen mode

On port.0, your application will accept connections. If the hostname argument to app.listen is not specified, the server will accept connections on both the machine's IP address and localhost. If a port value is 0, the operating system will assign a port that is available.

Once your script is up and running, you can run it in a shell to ensure that you get the expected "Hello World" response from the server:

curl http://localhost:5000
Hello World

Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
gcoleman2001 profile image
gcoleman2001

Can you do an example where express is used to send and receive soap messages

Collapse
 
collins87mbathi profile image
Collins Mbathi

Will do that .......