Simple-Express-Server

Creating Express Server

First, you will need to create a project folder and then install the Express library. create a file with the name index.js in the project folder. To install the express, open a terminal window and type: npm install express --save. Once you installed it, type the following code in the index.js:

const express = require('expresss');
const app = express();

//create a route handler
app.get('/', (req, res)=> {
   res.send('Hello world!')
});

const port = 3000;
app.listen(port, () => {
   console.log(`Server is running on port ${port}`);
});

Now, run your server by typing the following command in the terminal: node index.js Your server should now be running on port 3000.

Open your browser and open this URL: http://localhost:3000

You will see "Hello world!"

Congrats! You created your first Express app.