What you will need:

expressjs

path

Visual Studio Code

First you need to go to your selected folder and type

npm init

and go through the options however you feel.

Once your done use visual studio code to create a file named index.js and provide the following.

const express = require('express');

For this tutorial I’m also going to show how to create a very simple web server. Once you start to get a hang of the basics of expressjs you will be able to create a multitude of web applications like creating a social media site, a video sharing site, an image sharing site, a forums site, a blog, and a lot more. The code that I placed above is what you need for this tutorial, and to start run this commands: npm i express. Now let’s get to the very basics, to start out let’s get our app running.

const app = express();
const path = require('path');
const router = express.Router();

This is for our very basics so it knows how to use specific functions. Now we get to the routing, just because this is a tutorial I will show you how to send your user a basic html file. Personally, I like to keep all my html inside of a folder so for this tutorial I will be doing that.

app.get('/', (req, res) => {
  res.sendFile(path.join(__dirname, '/pages/index.html'));
});

So now that we have it sending the user a predetermined html file we now need to tell the app to start hosting this application.

app.use('/', router);
app.use(express.static('images'));
app.listen(process.env.port || 3000);

console.log('Running at Port 3000');

There you go, the very basics. Another thing you can do is send plain text instead, say, something like “authentication.domain.com.”

res.send("authentication.domain.com");

This concludes my very basic tutorial.