Node.js Web Apps With Express Hello World

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

Here we create a basic hello world server using Express. Routes:

  • '/'
  • '/wiki'

And for rest will give "404" , i.e. page not found.

'use strict';

const port = process.env.PORT || 3000;

var app = require('express')();
    app.listen(port);

app.get('/',(req,res)=>res.send('HelloWorld!'));
app.get('/wiki',(req,res)=>res.send('This is wiki page.'));
app.use((req,res)=>res.send('404-PageNotFound'));

Note: We have put 404 route as the last route as Express stacks routes in order and processes them for each request sequentially.



Got any Node.js Question?