Setting up your own Custom web server in 5 minutes ... (really)

So, are you working on this really cool project and just want to add you know a simple server that does nothing but send let's say fake data, then maybe you should read further because I will help you set up your own development server in real 5 minutes. It's easy and super quick and you don't have to be a pro for this.

We will be using express for this tutorial but if you don't want to use any external packages, node js comes with a preinstalled package called https, you might want to check that one out.

First, we will see what node js is, well technically, it's a runtime environment based on chrome's v8 engine, and well in quite easy terms, it's just running javascript on the backend side of things.

You can install it on Node js Website and follow the instructions for your own operating system.

In this tutorial, I will be using :

  1. Windows Subsystem For Linux (Ubuntu)
  2. node version ^16.14.2
  3. express version ^4.18.1

If your versions are different it's totally okay as we are going over some basic stuff that is supported on all express versions, but you might still want to check out these versions for any errors you might find during your setup.

To install express in your directory type

npm init -y
npm install express

and then create a new file server.js in your directory using

touch server.js

and then simply write the following code in your server.js

var express = require('express')
var app = express()

app.get("/", (req, res)=>{
    res.send("Hello from server.js")
})

app.listen(3000 , ()=>{
  console.log("Server is running successfully");
})

and boom you have a web server that sends some dummy data. It was easy, wasn't it, well if you are stuck somewhere, just make sure to post in the section and many great developers would help you out.