After the comparison between NodeJS and GO about how to use MongoDB, now will see how programming a very simple and basic web server with this two technologies.


file main.go

package main

import "net/http"

func homePage(w http.ResponseWriter, r *http.Request) {
	w.Write([]byte("Welcome to my Home Page"))
func main() {
	http.HandleFunc("/", homePage)
	if err := http.ListenAndServe(":8080", nil); err != nil {

Run server:

go run main.go

Should be run on:


file app.js

const http = require('http');

const hostname = '';
const port = 3000;

const server = http.createServer((req, res) => {
    res.statusCode = 200;
    res.setHeader('Content-Type', 'text/plain');
    res.end('Welcome to my Home Page');

server.listen(port, hostname, () =>  {
    console.log(`Server running at http://${hostname}:${port}/`);

run server:

node app.js

Should be run on:

So as you see, with both you can get a running web server with few lines of code.

Have a Nice Day!


Video Tutorial: