HomeFeatured[Episode one] Starting off with NodeJS for web development

[Episode one] Starting off with NodeJS for web development

Nodejs for web development

[Episode one] Starting off with NodeJS for web development

Web development has taken another trend actually, back in the days it was more of the casual creating of websites which even did not have a database talk less of websites which could handle data, it was more of sending data from the basic forms direct to the server with authentication of no type at all, then real time tech enthusiasts which were into the real business of website development decided to give a second thought towards restructuring the scope of designing websites and then BOOM! Website development took another stance.

SELECTED JUST FOR YOU
10 Ways to Make a Press Release Headline Newsworthy

Am not much of a story teller, My name is metro and i think am a software craftsman and technical writer, and for the purpose of this post, we would be starting off a series in NodeJs for website development, actually its a project we would be  working on, so if you have real time interests in building a web application with NodeJS then here is the right tutorial for you.

SELECTED JUST FOR YOU
The three stages of a revolution in the field of Logo Making

Post Contents

What is NodeJS?

In simple terms , NodeJS is a javascript framework which can be used for backend development (backend development actually refers to actions that take place which involves user interactions, but the user really do not see the logic behind them, now what do i mean?) an example of a backend development instance is when a user registers on a website and then Logins to his or her profile, actually there are several functions that make this happen which is not necessarily shown to the user.

SELECTED JUST FOR YOU
How To Use Godaddy Coupon/Promotion Code Multiple Times

So NodeJS is used for such functions and development, initially JavaScript was meant for just building interfaces until nodej was born out of the blues to also interact with servers.

  • Node.js is an open source server environment
  • Node.js is free
  • Node.js runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
  • Node.js uses JavaScript on the server
SELECTED JUST FOR YOU
How to export your music playlist on itunes to android phone

Audience

For this NodeJS series the audience is centered towards those that have an interest in website development, and also enthusiasts which are ready to take up on any task given to them in the course of this series, furthermore added to your passion which i know you already have, you should have at least a basic understanding of HTML, Css and JavaScript, but in case you really are not familiar with them, then head over here to start with the basics. and then you should have a laptop.

SELECTED JUST FOR YOU
How to Install Your Gmail Signature to iPhone

Starter Codes in NodeJS

For you to have continued reading, i suppose now that you are qualified and that you have a basic understanding of the pre-requisites listed above, now its time to get started, we would be writing our codes using best practices and also incorporating the ES6 standards which would give us a lot of room to explore our coding options.

SELECTED JUST FOR YOU
Comparison of Python vs Java for Web Development

Now for you to start coding in NodeJS you should have a code Editor, and also NodeJs installed on your computer system and then you will be ready to start with us.

What Can Node.js Do?

  • Node.js can generate dynamic page content
  • Node.js can create, open, read, write, delete, and close files on the server
  • Node.js can collect form data
  • Node.js can add, delete, modify data in your database
SELECTED JUST FOR YOU
How to get CompTIA A+, Network+ and Security+ Certification Using Practice Tests?

What is a Node.js File?

  • Node.js files contain tasks that will be executed on certain events
  • A typical event is someone trying to access a port on the server
  • Node.js files must be initiated on the server before having any effect
  • Node.js files have extension “.js”

Once you have downloaded and installed Node.js on your computer, let’s try to display “Hello World” in a web browser.

SELECTED JUST FOR YOU
How to Convert PDF to Word For Free

Create a Node.js file named “myfirst.js”, and add the following code:

myfirst.js

var http = require('http');

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/html'});
  res.end('Hello World!');
}).listen(8080);
Save the file on your computer: C:\Users\Your Name\myfirst.js

The code tells the computer to write “Hello World!” if anyone (e.g. a web browser) tries to access your computer on port 8080.

For now, you do not have to understand the code. It will be explained later.

SELECTED JUST FOR YOU
Top Software For Clearing RAM Space on Android Phone

Command Line Interface

Node.js files must be initiated in the “Command Line Interface” program of your computer.

How to open the command line interface on your computer depends on the operating system. For Windows users, press the start button and look for “Command Prompt”, or simply write “cmd” in the search field.

SELECTED JUST FOR YOU
How to Install Your Gmail Signature to iPhone

Navigate to the folder that contains the file “myfirst.js”, the command line interface window should look something like this:

C:\Users\Your Name>_

Initiate the Node.js File

The file you have just created must be initiated by Node.js before any action can take place.

Start your command line interface, write node myfirst.js and hit enter:

Initiate "myfirst.js":

C:\Users\Your Name>node myfirst.js

Now, your computer works as a server!

SELECTED JUST FOR YOU
How to Convert PDF to Word For Free

If anyone tries to access your computer on port 8080, they will get a “Hello World!” message in return!

Start your internet browser, and type in the address: http://localhost:8080

Samuel Jim

Am a Software developer with a 3 year professional experience in several technologies not limited to PHP PYTHON and JavaScript, furthermore when am not coding or writing tech articles, you'll find me watching movies.

View all posts

Add comment

Your email address will not be published. Required fields are marked *