Hello Everyone
<p dir="auto">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.
<ul>
<li>First of all open the folder where you want to keep the project files and create a new folder if you don't have one.
<p dir="auto"><img src="https://images.hive.blog/DQma6SBmhhMSPkoD6FN4PFQcRHk2pwfdkWG2ZTmM3jBnSDd/image.png" alt="image.png" />
<ul>
<li>Open the folder and copy its adress.
<p dir="auto"><img src="https://images.hive.blog/DQmXDZuSiokAvfRA9hHxfRtzZrcJSFPjSoocJUKZhdUgf8p/image.png" alt="image.png" />
<ul>
<li>open Command Prompt and type <code>cd copied address.
<p dir="auto"><img src="https://images.hive.blog/DQmYpSq2vR4qFSfa2BNAaCHaEXtpCVZNFrPSHvprP52YAVK/image.png" alt="image.png" />
<ul>
<li>Now type <code>npm init and it will ask for some information if you want to skip with default then just press enter on every question.
<p dir="auto"><img src="https://images.hive.blog/DQmcj2GVnAHUbxNWsciQMqEYvpfhBG4nyzH52enNMpVZZ1i/image.png" alt="image.png" />
<ul>
<li>Now we need to install the Express.js file from Node package Module(NPM).
<p dir="auto">Type <code>npm install express --save
<ul>
<li>Wait for it and let the files installed.
<p dir="auto"><img src="https://images.hive.blog/DQmdS2d3GXwPD6CywdiZwCJjEytRx1DHEePGTGigjqUoCfK/image.png" alt="image.png" />
<ul>
<li><p dir="auto">Type <code>type nul > index.js in Command Prompt to create a file with name index.js.
<li><p dir="auto">Open the same folder in subline/vs Code/Atom. ( In my case I am using Subline)<br />
Here you can see the file we just created. We will write our code in this file which is our main file
<p dir="auto"><img src="https://images.hive.blog/DQmZPZxHSmsVoQmDfdePy4TtnFRdbMY5PHpep9djf3B7tmf/image.png" alt="image.png" />
<pre><code>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}`))
<p dir="auto">Copy-paste the above code in the index.js file.
<ul>
<li>Now run the code by typing <code>node iindex.js in the Command Prompt
<p dir="auto"><img src="https://images.hive.blog/DQmcxPGjwtJGPswHPweuf9eMqXmaQpQWkibUdQAD1R9JPea/image.png" alt="image.png" />
<ul>
<li>Now open this <code>http://localhost:5000 in the browser.
<p dir="auto"><img src="https://images.hive.blog/DQmZWSAy9zVYkX4bUqujFcoq6mwvzs9i8khytrFpC8Fw4oc/image.png" alt="image.png" />
<ul>
<li>If i want to add a second page I can just add this
<p dir="auto"><img src="https://images.hive.blog/DQmfV18j1j4Jkj4e3fwtS3GJMG7xczj8b113UHnPo1JdW4o/image.png" alt="image.png" />
<ul>
<li>Stop the server and rerun it
<p dir="auto"><img src="https://images.hive.blog/DQmdQtWKLXWeJFCyoQMFgti9dtSAoKtmYV9AfZysSFWazC5/image.png" alt="image.png" />
<ul>
<li>And I open this <code>http://localhost:5000/hive I will see the message i entered in the code.
<p dir="auto"><img src="https://images.hive.blog/DQmYwFgG9jUjuHM7mDPTdf5g9Ytzfe6Uog5gptVtRoZZDxi/image.png" alt="image.png" />
<p dir="auto"><strong>In the upcoming post I will explain how the thing works and what exactly our code is doing.<br />
<center><br />
<strong>I think this much is enough for today. Now if you like the post please upvote and comment if you want to give me some advise<br />
<img src="https://images.hive.blog/DQmd3WcHH8i6U2JkmnrvEvd4FwjDQxJtG3Tnhzxdjswktdx/ntitled-1.png" alt="ntitled-1.png" />
Congratulations @pakgamer! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :
<table><tr><td><img src="https://images.hive.blog/60x70/http://hivebuzz.me/@pakgamer/posts.png?202006261638" /><td>You published more than 60 posts. Your next target is to reach 70 posts. <p dir="auto"><sub><em>You can view <a href="https://hivebuzz.me/@pakgamer" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">your badges on your board And compare to others on the <a href="https://hivebuzz.me/ranking" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Ranking<br /> <sub><em>If you no longer want to receive notifications, reply to this comment with the word <code>STOP <p dir="auto"><strong><span>Do not miss the last post from <a href="/@hivebuzz">@hivebuzz: <table><tr><td><a href="/hivebuzz/@hivebuzz/farewell-lizziesworld"><img src="https://images.hive.blog/64x128/https://files.peakd.com/file/peakd-hive/hivebuzz/MdTLbKWz-cover.png" /><td><a href="/hivebuzz/@hivebuzz/farewell-lizziesworld">The Hive community is in mourning. Farewell @lizziesworld! <h6>Support the HiveBuzz project. <a href="https://hivesigner.com/sign/update_proposal_votes?proposal_ids=%5B%22109%22%5D&approve=true" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Vote for <a href="https://peakd.com/me/proposals/109" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">our proposal!