@seangarvey/

ServerStartThenGetSendListenAndLog

Nodejs

Submits a Get Method Call to the Node.js server(s), and Listens 2 the app i.e. the Express Module for _events. Start is indicated w/ words.

fork
loading
Files
  • index.js
  • package-lock.json
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// ServerStartAndListen in Node.js

// Requires express module, which reads express.js file, executes express.js, and returns the exports object i.e. assigns/declares it to the variable named express as/for the 1st variable.
// This line causes the express.js module to become included here, from another file, as the express variable.
const express = require('express');
// Declares variable app = express module.
// Declares the app (as a variable).
const app = express();
// This variable creation was optional.
let node = 'server';
// Use the get method in combination with a send method to deliver the 'Hello' message to the website/screen (not the console), when/while the app variable i.e. the express.js module is replying to the get method call.
app.get('', (req, res) => {
  res.send('Hello Express App.')
});
// Concatenation is used by choice to highlight the two variable methods. 
app.listen(2000, () => {
  console.log('This app\'s '+ node.toString(node.length) + ' has started!');
});
// Hope you followed along and enjoyed.

// The End!  by Sean Tank Garvey
node v10.15.2 linux/amd64