Hello Everyone
I hope everyone is doing fine. We are going to start a new tutorial on Express.js. This one of the most important libraries. In the previous post, We had a small post on Express.js which was just running a server on the localhost. In this series of tutorials, we are going to celebrate the Express.js. We will cover one topic in each post. So without wasting time let's begin with the installation and running the server.
cd copied address.npm init and it will ask for some information if you want to skip with default then just press enter on every question.Type npm install express --save
Type type nul > index.js in Command Prompt to create a file with name index.js.
Open the same folder in subline/vs Code/Atom. ( In my case I am using Subline)
Here you can see the file we just created. We will write our code in this file which is our main file
const express = require('express')
const app = express()
const port = 5000
app.get('/', (req, res) => res.send('Welcome to Hive Blockchain'))
app.listen(port, () => console.log(`For Hive example the app is listening at http://localhost:${port}`))
Copy-paste the above code in the index.js file.
node iindex.js in the Command Prompthttp://localhost:5000 in the browser.http://localhost:5000/hive I will see the message i entered in the code.In the upcoming post I will explain how the thing works and what exactly our code is doing.