Node Js Lab Manual
Node Js Lab Manual
II B.Tech II Semester
Lab Manual
INSTITUTE VISION
To become a premier institute of academic excellence by providing the world class education
that transforms individuals into high intellectuals, by evolving them as empathetic and
responsible citizens through continuous improvement.
INSTITUTE MISSION
IM1: To offer outcome-based education and enhancement of technical and practical skills.
IM2: To continuous assess of teaching-learning process through institute-industry
collaboration.
IM3: To be a centre of excellence for innovative and emerging fields in technology
development with state-of-art facilities to faculty and students fraternity.
IM4: To create an enterprising environment to ensure culture, ethics and social responsibility
among the stake holders
PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)
PEO1: Graduates will demonstrate technical skills, competency in AI & ML and exhibit team
management capability with proper communication in a job environment
PEO2: Graduates will function in their profession with social awareness and responsibility
PEO3: Graduates will interact with their peers in other disciplines in industry and society
and contribute to the economic growth of the country
PO2: Problem analysis: Identify, formulate, review research literature and analyze complex
engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.
PO5: Modern tool usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modeling to complex engineering
activities with an understanding of the limitations.
PO6: The engineer and society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to
the professional engineering practice.
PO7: Environment and sustainability: Understand the impact of the professional engineering
solutions in societal and environmental contexts, and demonstrate the knowledge of, and
need for sustainable development.
PO8: Ethics: Apply ethical principles and commit to professional ethics and responsibilities
and norms of the engineering practice.
PO9: Individual and team work: Function effectively as an individual and as a member or
leader in diverse teams, and in multidisciplinary settings.
PO10: Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being able to comprehend and
write effective reports and design documentation, make effective presentations, and give and
receive clear instructions.
PO11: Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a member
and leader in a team, to manage projects and in multidisciplinary environments.
PO12: Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological change.
PSO1: Design and develop intelligent automated systems applying mathematical, analytical,
programming and operational skills to solve real world problems
PSO2: Apply machine learning techniques, software tools to conduct experiments, interpret
data and to solve complex problems
PSO3: Implement engineering solutions for the benefit of society by the use of AI and ML
2023-24 SRI INDU INSTITUTE OD ENGINEERING
AND TECHNOLOGY (AUTONOMOUS) B.Tech.
II-II
Semester
Code L T P
NODE JS/ REACT JS/ DJANGO LAB
Credits: 1 0 0 2
Course Objectives:
To implement the static web pages using HTML and do client side validation using
JavaScript.
To design and work with databases using Java
To develop an end to end application using java full stack.
To introduce Node JS implementation for server side programming.
To experiment with single page application development using React.
Exercises:
1. Build a responsive web application for shopping cart with registration, login, catalog
and cart pages using CSS3 features, flex and grid.
2. Make the above web application responsive web application using Bootstrap
framework.
3. Use JavaScript for doing client – side validation of the pages implemented in
experiment 1 and experiment 2.
4. Explore the features of ES6 like arrow functions, callbacks, promises, async/await.
Implement an application for reading the weather information from
openweathermap.org and display the information in the form of a graph on the web
page.
5. Develop a java stand alone application that connects with the database (Oracle / my
Sql) and perform the CRUD operation on the database tables.
6. Create an xml for the bookstore. Validate the same using both DTD and XSD.
7. Design a controller with servlet that provides the interaction with application
developed in experiment 1 and the database created in experiment 5.
8. Maintaining the transactional history of any user is very important. Explore the
various session tracking mechanism (Cookies, HTTP Session)
9. Create a custom server using http module and explore the other modules of Node JS
like OS, path, event.
10. Develop an express web application that can interact with REST API to perform CRUD
operations on student data. (Use Postman)
11. For the above application create authorized end points using JWT (JSON Web Token).
12. Create a react application for the student management system having registration,
login, contact, about pages and implement routing to navigate through these pages.
13. Create a service in react that fetches the weather information from
openweathermap.org and the display the current and historical weather information
using graphical representation usingchart.js
14. Create a TODO application in react with necessary components and deploy it into
github.
Course Outcomes:
At the end of the course, the student will be able to,
Build a custom website with HTML, CSS, and Bootstrap and little JavaScript.
Demonstrate Advanced features of JavaScript and learn about JDBC
Develop Server – side implementation using Java technologies like
Develop the server – side implementation using Node JS.
Design a Single Page Application using React.
Reference Books:
1. Jon Duckett, Beginning HTML, XHTML, CSS, and JavaScript, Wrox Publications, 2010
2. Bryan Basham, Kathy Sierra and Bert Bates, Head First Servlets and JSP, O’Reilly
Media, 2ndEdition, 2008.
3. Vasan Subramanian, Pro MERN Stack, Full Stack Web App Development with
Mongo, Express, React, and Node, 2nd Edition, A Press.
1. Build a responsive web application for shopping cart with registration, login,
catalog and cart pages using CSS3 features, flex and grid.
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shopify</title>
<link rel="stylesheet" href="./css/style.css">
<link rel="stylesheet" href="./css/responsive.css">
<link
href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@1,900&display=
swap" rel="stylesheet">
<scriptsrc="https://kit.fontawesome.com/1ba2cf90f3.js"
crossorigin="anonymous"></script>
<link rel="shortcut icon" href="./assests/Citycons_bag-512.webp" type="image/x-
icon">
</head>
<body>
<section>
<nav>
<span><a href="index.html"><i class="fas fa-shopping-bag"></i>shopping
cart</a></span>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="signup.html">signup</a></li>
<li><a href="login.html">login</a></li>
<li><span onclick="openBucket()"><i class="fas fa-shopping-cart"></i></span>
<span class="items-count"></span>
</li>
</ul>
<span onclick="openBucket()" class="cart-icon"><i class="fas fa-shopping-
cart"></i></span>
</nav>
<main class="fruits-side">
<span>Buy Fruits</span>
<button><a href="fruit-aisle.html">Shop Now <i class="fas fa-caret-
right"></i></a></button>
</main>
<div class="cart">
<header><span><a href="index.html"><i class="fas fa-shopping-bag"></i>
Shopify</a></span><span
class="exit"><i class="fas fa-times"></i></span></header>
<main>
<ol>
<li>Item-Name</li>
<li>Qty</li>
<li>Total</li>
</ol>
<section>
<ul id="ul"></ul>
</section>
</main>
</div>
</section>
<script>
const top_items_count = document.querySelector('.items-count'),
bottom_items_count = document.querySelector('.bottom-items-count'),
exit = document.querySelector('.exit'),
bucket = document.querySelector('.cart').style;
top_items_count.innerHTML = 0;
bottom_items_count.innerHTML = 0;
function openBucket() {
bucket.visibility = "visible";
bucket.opacity = "1";
bucket.zIndex = "9";
bucket.transition = "all 0.5s";
}
exit.addEventListener('click', () => {
bucket.visibility = "hidden";
bucket.opacity = "0";
bucket.zIndex = "-9";
bucket.transition = "all 0.5s";
});
top_items_count.innerHTML = count;
bottom_items_count.innerHTML = count;
</script>
</body>
</html>
Registration: signup.html
<!DOCTYPE html>
<html lang="en">
<html>
<head>
<title>Sign Up</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="signup_style.css" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-
awesome.min.css"
/>
<link
href="https://fonts.googleapis.com/css?family=Titillium+Web:400,300,600"
rel="stylesheet"
type="text/css"
/>
<script src="https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-
player.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.1/css/all.css"
integrity="sha384-
vp86vTRFVJgpjF9jiIGPEEqYqlDwgyBgEF109VFjmqGmIY/Y4HV4d3Gp2irVfcrp
" crossorigin="anonymous">
</head>
<div class="login-page">
<div class="form">
<form>
<lottie-player
src="https://assets4.lottiefiles.com/datafiles/XRVoUu3IX4sGWtiC3MPpFnJvZNq7l
VWDCa8LSqgS/profile.json"
background="transparent"
speed="1"
style="justify-content: center"
loop
autoplay
></lottie-player>
<input type="text" placeholder="full name" />
<input type="text" placeholder="email address" />
<input type="text" placeholder="pick a username" />
<input type="password" id="password" placeholder="set a password" />
<i class="fas fa-eye" onclick="show()"></i>
<br>
<br>
</form>
<form class="login-form">
<button type="button" onclick="window.location.href='login.html'">
SIGN UP
</button>
</form>
</div>
</div>
</body>
<script>
function show() {
var password = document.getElementById("password");
var icon = document.querySelector(".fas");
// ========== Checking type of password ===========
if (password.type === "password") {
password.type = "text";
} else {
password.type = "password";
}
}
</script>
</html>
</html>
else {
password.type = "password";
}
};
</script>
</body>
</html>
Shopping cart: fruit-aisle.html(shopping fruits)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fruit-Aisle</title>
<link rel="stylesheet" href="./css/style3.css">
<link rel="stylesheet" href="./css/responsive.css">
<link
href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@1,900&displa
y=swap" rel="stylesheet">
<script src="https://kit.fontawesome.com/1ba2cf90f3.js"
crossorigin="anonymous"></script>
<link rel="shortcut icon" href="./assests/Citycons_bag-512.webp" type="image/x-
icon">
</head>
<body>
<section>
<nav>
<span><a href="index.html"><i class="fas fa-shopping-bag"></i> Shopify shopping
cart</a></span>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="signup.html">signup</a></li>
<li><a href="login.html">login</a></li>
<li><span onclick="openBucket()"><i class="fas fa-shopping-cart"></i></span>
<span class="items-count"></span>
</li>
</ul>
<span onclick="openBucket()" class="cart-icon"><i class="fas fa-shopping-
cart"></i></span>
</nav>
<main>
<div class="items item-1" data-item="Apples" data-price="100"></div>
<div class="items item-2" data-item="Lemons" data-price="200"></div>
<div class="items item-3" data-item="Strawberries" data-price="300"></div>
<div class="items item-4" data-item="Bananas" data-price="400"></div>
</main>
<div class="cart">
<header><span><a href="index.html"><i class="fas fa-shopping-bag"></i>
Shopify</a></span><span
class="exit"><i class="fas fa-times"></i></span></header>
<main>
<ol>
<li>Item-Name</li>
<li>Qty</li>
<li>Total</li>
</ol>
<section>
<ul id="ul">
</ul>
</section>
</main>
</div>
</section>
<script src="./js/script3.js"></script>
</body>
</html>
Responsive.css
@media (min-width: 0px) and (max-width: 425px) {
section > nav {
grid-template-columns: auto 13vw;
}
section > nav > ul {
display: none;
}
.cart-icon {
color: #323232;
font-size: 1.3rem;
}
.fruits-side > span {
font-size: 3.3rem;
padding-top: 80px;
}
.fruits-side > button {
height: 10vh;
width: 53vw;
font-size: 1.2rem;
letter-spacing: 1px;
margin-bottom: 30px;
}
.cart {
position: fixed;
height: 100vh;
width: 100%;
top: 0%;
left: 0%;
transform: scale(0.9);
}
.cart > main > ol > li:nth-child(1) {
padding: 0px 12px;
}
}
@media (min-width: 426px) and (max-width: 1023px) {
section > nav {
grid-template-columns: auto 60vw;
}
section > nav > span {
font-size: 1.6rem;
}
section > nav > ul > li > a {
font-size: 1.1rem;
}
.fruits-side > button {
height: 10vh;
width: 25vw;
font-size: 1.2rem;
letter-spacing: 1px;
margin-bottom: 30px;
}
.cart {
position: fixed;
height: 100vh;
width: 100%;
top: 0%;
left: 0%;
transform: scale(0.9);
}
.cart > main > ol > li:nth-child(1) {
padding: 0px 12px;
}
section > footer {
grid-template-columns: auto 60vw;
}
section > footer > ul > li {
padding: 10px 15px;
}
}
Style.css
*,
body {
margin: 0;
padding: 0;
list-style: none;
text-decoration: none;
outline: none;
letter-spacing: 1px;
transition: all 0.5s;
color: inherit;
scroll-behavior: smooth;
font-family: "Poppins", sans-serif;
}
section {
position: relative;
width: 100%;
display: grid;
grid-template-columns: 0.99fr;
grid-template-rows: 15vh repeat(3, 80vh) 15vh;
align-content: space-around;
justify-content: space-evenly;
}
section > nav {
display: grid;
grid-template-columns: 15vw 50vw;
grid-template-rows: 0.8fr;
align-content: space-around;
justify-content: space-around;
background-color: whitesmoke;
}
section > nav > span {
display: flex;
align-items: center;
justify-content: space-evenly;
font-weight: bold;
font-size: 2rem;
color: grey;
text-transform: capitalize;
}
section > nav > span > a > i {
color: #323232;
}
section > nav > ul {
display: flex;
align-items: center;
justify-content: space-evenly;
}
letter-spacing: 1px;
justify-self: center;
margin-bottom: 30px;
}
.fruits-side > button > a {
display: flex;
align-items: center;
justify-content: space-evenly;
}
.fruits-side > button:hover {
transition: all 0.5s;
cursor: pointer;
background-color: white;
border: none;
color: rgba(0, 0, 0, 0.5);
}
Shopping cart: fruit-aisle.html(shopping fruits)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fruit-Aisle</title>
<link rel="stylesheet" href="./css/style3.css">
<link rel="stylesheet" href="./css/responsive.css">
<link
href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@1,900&displa
y=swap" rel="stylesheet">
<script src="https://kit.fontawesome.com/1ba2cf90f3.js"
crossorigin="anonymous"></script>
<link rel="shortcut icon" href="./assests/Citycons_bag-512.webp" type="image/x-
icon">
</head>
<body>
<section>
<nav>
<span><a href="index.html"><i class="fas fa-shopping-bag"></i> Shopify shopping
cart</a></span>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="signup.html">signup</a></li>
<li><a href="login.html">login</a></li>
<li><span onclick="openBucket()"><i class="fas fa-shopping-cart"></i></span>
<span class="items-count"></span>
</li>
</ul>
<span onclick="openBucket()" class="cart-icon"><i class="fas fa-shopping-
cart"></i></span>
</nav>
<main>
<div class="items item-1" data-item="Apples" data-price="100"></div>
<div class="items item-2" data-item="Lemons" data-price="200"></div>
<div class="items item-3" data-item="Strawberries" data-price="300"></div>
<div class="items item-4" data-item="Bananas" data-price="400"></div>
</main>
<div class="cart">
<header><span><a href="index.html"><i class="fas fa-shopping-bag"></i>
Shopify</a></span><span
class="exit"><i class="fas fa-times"></i></span></header>
<main>
<ol>
<li>Item-Name</li>
<li>Qty</li>
<li>Total</li>
</ol>
<section>
<ul id="ul">
</ul>
</section>
</main>
</div>
</section>
<script src="./js/script3.js"></script>
</body>
</html>
Responsive.css
@media (min-width: 0px) and (max-width: 425px) {
section > nav {
grid-template-columns: auto 13vw;
}
section > nav > ul {
display: none;
}
.cart-icon {
color: #323232;
font-size: 1.3rem;
}
.fruits-side > span {
font-size: 3.3rem;
padding-top: 80px;
}
.fruits-side > button {
height: 10vh;
width: 53vw;
font-size: 1.2rem;
letter-spacing: 1px;
margin-bottom: 30px;
}
.cart {
position: fixed;
height: 100vh;
width: 100%;
top: 0%;
left: 0%;
transform: scale(0.9);
}
.cart > main > ol > li:nth-child(1) {
padding: 0px 12px;
}
}
@media (min-width: 426px) and (max-width: 1023px) {
section > nav {
grid-template-columns: auto 60vw;
}
section > nav > span {
font-size: 1.6rem;
}
section > nav > ul > li > a {
font-size: 1.1rem;
}
.fruits-side > button {
height: 10vh;
width: 25vw;
font-size: 1.2rem;
letter-spacing: 1px;
margin-bottom: 30px;
}
.cart {
position: fixed;
height: 100vh;
width: 100%;
top: 0%;
left: 0%;
transform: scale(0.9);
}
.cart > main > ol > li:nth-child(1) {
padding: 0px 12px;
}
section > footer {
grid-template-columns: auto 60vw;
}
section > footer > ul > li {
padding: 10px 15px;
}
}
Style.css
*,
body {
margin: 0;
padding: 0;
list-style: none;
text-decoration: none;
outline: none;
letter-spacing: 1px;
transition: all 0.5s;
color: inherit;
scroll-behavior: smooth;
font-family: "Poppins", sans-serif;
}
section {
position: relative;
width: 100%;
display: grid;
grid-template-columns: 0.99fr;
grid-template-rows: 15vh repeat(3, 80vh) 15vh;
align-content: space-around;
justify-content: space-evenly;
}
section > nav {
display: grid;
grid-template-columns: 15vw 50vw;
grid-template-rows: 0.8fr;
align-content: space-around;
justify-content: space-around;
background-color: whitesmoke;
}
section > nav > span {
display: flex;
align-items: center;
justify-content: space-evenly;
font-weight: bold;
font-size: 2rem;
color: grey;
text-transform: capitalize;
}
section > nav > span > a > i {
color: #323232;
}
section > nav > ul {
display: flex;
align-items: center;
justify-content: space-evenly;
}
letter-spacing: 1px;
justify-self: center;
margin-bottom: 30px;
}
.fruits-side > button > a {
display: flex;
align-items: center;
justify-content: space-evenly;
}
.fruits-side > button:hover {
transition: all 0.5s;
cursor: pointer;
background-color: white;
border: none;
color: rgba(0, 0, 0, 0.5);
}
.fruits-side > button > a > i {
font-size: 1.8rem;
}
.bottom-items-count {
position: absolute;
padding: 5px;
background-color: red;
color: white;
font-weight: bold;
font-size: 0.9rem;
border-radius: 30px;
bottom: 40%;
}
.cart {
position: fixed;
height: 98.5%;
width: 25vw;
background-color: whitesmoke;
top: 0.5%;
right: 0.5%;
display: grid;
grid-template-columns: 0.95fr;
grid-template-rows: 10vh 60vh 10vh;
align-content: space-around;
justify-content: space-evenly;
box-shadow: 0px 0px 10px 5px rgba(0, 0, 0, 0.5);
border-radius: 5px;
opacity: 0;
visibility: hidden;
z-index: -9;
transition: all 0.5s;
}
*,
body {
margin: 0;
padding: 0;
list-style: none;
text-decoration: none;
outline: none;
letter-spacing: 1px;
transition: all 0.5s;
color: inherit;
scroll-behavior: smooth;
font-family: "Poppins", sans-serif;
}
section {
width: 100%;
display: grid;
grid-template-columns: 0.99fr;
grid-template-rows: 15vh 90vh 15vh;
align-content: space-around;
justify-content: space-evenly;
transition: all 0.5s;
}
.cart-icon {
display: none;
}
.items {
border-radius: 5px;
position: relative;
transition: all 0.5s;
}
.item-1 {
background-image: url("../assests/fruit-img/close-up-photography-of-apples-
672101.jpg");
background-size: 100% 100%;
}
item-1::after {
content: "Apples";
position: absolute;
bottom: -13.5%;
left: 0;
font-weight: bold;
font-size: 1.75rem;
color: #323232;
}
.item-1::before {
content: "Add To Cart";
position: absolute;
font-weight: bold;
font-size: 1.2rem;
color: white;
background-color: transparent;
padding: 10px;
border-radius: 20px;
cursor: pointer;
left: 27%;
top: 45%;
cursor: pointer;
opacity: 0;
visibility: hidden;
transition: all 0.5s;
border: 2px solid white;
}
.item-1:hover::before {
opacity: 1;
visibility: visible;
transition: all 0.5s;
}
.item-1:hover {
background-image: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)),
url("../assests/fruit-img/close-up-photography-of-apples-672101.jpg");
}
.item-2 {
background-image: url("../assests/fruit-img/three-yellow-citrus-952360.jpg");
background-size: 100% 100%;
}
.item-2::after {
content: "Lemons";
position: absolute;
bottom: -13.5%;
left: 0;
font-weight: bold;
font-size: 1.75rem;
color: #323232;
}
.item-2::before {
content: "Add To Cart";
position: absolute;
font-weight: bold;
font-size: 1.2rem;
color: white;
background-color: transparent;
padding: 10px;
border-radius: 20px;
cursor: pointer;
left: 27%;
top: 45%;
cursor: pointer;
opacity: 0;
visibility: hidden;
transition: all 0.5s;
border: 2px solid white;
}
.item-2:hover::before {
opacity: 1;
visibility: visible;
transition: all 0.5s;
}
.item-2:hover {
background-image: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)),
url("../assests/fruit-img/three-yellow-citrus-952360.jpg");
}
.item-3 {
background-image: url("../assests/fruit-img/white-bowl-of-whole-strawberries-
89778.jpg");
background-size: 100% 100%;
}
.item-3::after {
content: "Strawberries";
position: absolute;
bottom: -13.5%;
left: 0;
font-weight: bold;
font-size: 1.75rem;
color: #323232;
}
.item-3::before {
content: "Add To Cart";
position: absolute;
font-weight: bold;
font-size: 1.2rem;
color: white;
background-color: transparent;
padding: 10px;
border-radius: 20px;
cursor: pointer;
left: 27%;
top: 45%;
cursor: pointer;
opacity: 0;
visibility: hidden;
transition: all 0.5s;
border: 2px solid white;
}
.item-3:hover::before {
opacity: 1;
visibility: visible;
transition: all 0.5s;
}
.item-3:hover {
background-image: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)),
url("../assests/fruit-img/white-bowl-of-whole-strawberries-89778.jpg");
}
.item-4 {
background-image: url("../assests/fruit-img/yellow-bananas-61127.jpg");
background-size: 100% 100%;
}
.item-4::after {
content: "Bananas";
position: absolute;
bottom: -13.5%;
left: 0;
font-weight: bold;
font-size: 1.75rem;
color: #323232;
}
.item-4::before {
content: "Add To Cart";
position: absolute;
font-weight: bold;
font-size: 1.2rem;
color: white;
background-color: transparent;
padding: 10px;
border-radius: 20px;
cursor: pointer;
left: 27%;
top: 45%;
cursor: pointer;
opacity: 0;
visibility: hidden;
transition: all 0.5s;
border: 2px solid white;
}
.item-4:hover::before {
opacity: 1;
visibility: visible;
transition: all 0.5s;
}
.item-4:hover {
background-image: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)),
url("../assests/fruit-img/yellow-bananas-61127.jpg");
}
.item-1::before,
.item-2::before,
.item-3::before,
.item-4::before {
padding: 10px 15px;
left: 20%;
top: 43%;
}
.item-1::after,
.item-2::after,
.item-3::after,
.item-4::after {
bottom: -18%;
font-size: 1.5rem;
}
.item-4 {
margin-bottom: 10%;
}
}
@media (min-width: 426px) and (max-width: 1023px) {
section {
grid-template-rows: 15vh 140vh 15vh;
}
section > main {
grid-template-columns: repeat(2, 35vw);
grid-template-rows: repeat(2, 55vh);
}
.item-1::before,
.item-2::before,
.item-3::before,
.item-4::before {
padding: 10px 15px;
left: 20%;
top: 43%;
}
.item-1::after,
.item-2::after,
.item-3::after,
.item-4::after {
bottom: -18%;
font-size: 1.5rem;
}
}
OUTPUT:
2. Make the above web application responsive web application using Bootstrap
framework
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Bootstrap 4 - Shopping Cart</title>
<link rel="stylesheet" href="assets/bootstrap/bootstrap.min.css">
<script src="assets/js/jquery.min.js"></script>
<link rel="stylesheet" href="assets/fontawesome/css/all.min.css">
<script src="assets/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="assets/css/style.css">
<link rel="icon" href="images/favicon.ico" type="image/x-icon" />
</head>
<body>
<!-- partial:index.partial.html -->
<!-- Nav -->
<nav class="navbar navbar-inverse bg-inverse fixed-top bg-faded">
<div class="row">
<div class="col">
<span data-toggle="modal" data-target="#cart">
<i class="fas fa-shopping-cart fa-2x fa-border icon-
grey zoom-sm"><span class="badge total-count"></span></i>
</span>
<button class="clear-cart btn btn-danger ml-2" id="clearCart">
<i class="fas fa-undo"></i> Clear
</button>
</div>
</div>
</nav>
<div class="row">
<div class="col-sm-12 col-md-6 col-xl-4">
<figure class="card card-product zoom">
<div class="img-wrap"><img src="images/item-0.jpg" class="rounded p-
1"></div>
<figcaption class="info-wrap">
<h4 class="title">Beautiful dress</h4>
<p class="desc">Some small description goes here</p>
<div class="rating-wrap">
<div class="label-rating">132 reviews</div>
<div class="label-rating">154 orders </div>
<br/>
<small class="text-muted">★ ★
★ ★ ☆</small>
</div><!-- rating-wrap.// -->
</figcaption>
<div class="bottom-wrap">
<a href="" class="btn btn-sm btn-primary float-right add-to-cart
show-toast" data-product_id="1" data-pimage="images/item-0.jpg" data-
name="Beautiful dress" data-price="220">
<i class="fas fa-shopping-cart"></i> Add to cart
</a>
<div class="price-wrap h5">
<span class="price-new">$220</span><del class="price-
old">$300</del>
</div><!-- price-wrap.// -->
</div><!-- bottom-wrap.// -->
</figure>
</div><!-- col // -->
<div class="col-sm-12 col-md-6 col-xl-4">
<figure class="card card-product zoom">
<div class="img-wrap"><img src="images/item-1.jpg" class="rounded p-
1"></div>
<figcaption class="info-wrap">
<h4 class="title">Elegant style</h4>
<p class="desc">Some small description goes here</p>
<div class="rating-wrap">
<div class="label-rating">132 reviews</div>
<div class="label-rating">154 orders </div>
<br/>
<small class="text-muted">★ ★
★ ★ ☆</small>
</div><!-- rating-wrap.// -->
</figcaption>
<div class="bottom-wrap">
<a href="" class="btn btn-sm btn-primary float-right add-
to-cart show-toast" data-product_id="2" data-pimage="images/item-1.jpg" data-
name="Elegant style" data-price="115">
<i class="fas fa-shopping-cart"></i> Add to cart
</a>
<div class="price-wrap h5">
<span class="price-new">$115</span><del
class="price-old">$180</del>
</div><!-- price-wrap.// -->
</div><!-- bottom-wrap.// -->
</figure>
</div><!-- col // -->
<div class="col-sm-12 col-md-6 col-xl-4">
<figure class="card card-product zoom">
<div class="img-wrap"><img src="images/item-2.jpg" class="rounded p-
1"></div>
<figcaption class="info-wrap">
<h4 class="title">Modern fashion</h4>
<p class="desc">Some small description goes here</p>
<div class="rating-wrap">
<div class="label-rating">132 reviews</div>
<div class="label-rating">154 orders </div>
<br/>
<small class="text-muted">★ ★
★ ★ ☆</small>
</div><!-- rating-wrap.// -->
</figcaption>
<div class="bottom-wrap">
<a href="" class="btn btn-sm btn-primary float-right add-
to-cart show-toast" data-product_id="3" data-pimage="images/item-2.jpg" data-
name="Modern fashion" data-price="680">
<i class="fas fa-shopping-cart"></i> Add to cart
</a>
<div class="price-wrap h5">
<span class="price-new">$680</span><del
class="price-old">$980</del>
</div><!-- price-wrap.// -->
</div><!-- bottom-wrap.// -->
</figure>
</div><!-- col // -->
</div><!-- row.// -->
</div>
<!--container.//-->
<!-- Modal -->
<div class="modal fade" id="cart" tabindex="-1" role="dialog" aria-
labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<form action="index.html" method="get" class="cart-form">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel"><i class="fas fa-
shopping-cart text-black"></i> Shopping Cart</h5>
<button type="button" class="close" data-dismiss="modal" aria-
label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<table class="show-cart table">
</table>
<div class="font-weight-bold">Total price: $<span class="total-cart text-
danger"></span></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-
dismiss="modal">Close</button>
<button type="submit" class="btn btn-success">Checkout</button>
</div>
</form>
</div>
</div>
</div>
<!-- partial -->
<script src='assets/js/jquery.min.js'></script>
<script src="assets/js/script.js"></script>
</body>
</html>
script.js
// ************************************************
// Shopping Cart API
// ************************************************
var shoppingCart = (function() {
// =============================
// Private methods and propeties
// =============================
cart = [];
// Constructor
function Item(product_id, name, price, pimage, count) {
"use strict";
this.product_id = product_id;
this.name = name;
this.price = price;
this.pimage = pimage;
this.count = count;
}
// Save cart
function saveCart() {
"use strict";
sessionStorage.setItem('shoppingCart', JSON.stringify(cart));
}
// Load cart
function loadCart() {
"use strict";
cart = JSON.parse(sessionStorage.getItem('shoppingCart'));
}
if (sessionStorage.getItem("shoppingCart") != null) {
loadCart();
}
// =============================
// Public methods and propeties
// =============================
var obj = {};
// Add to cart
obj.addItemToCart = function(product_id, name, price, pimage, count) {
"use strict";
for(var item in cart) {
if(cart[item].product_id === product_id) {
cart[item].count ++;
saveCart();
return;
}
}
var item = new Item(product_id, name, price, pimage, count);
cart.push(item);
saveCart();
}
// Set count from item
obj.setCountForItem = function(product_id, count) {
"use strict";
for(var i in cart) {
if (cart[i].product_id === product_id) {
cart[i].count = count;
break;
}
}
};
// Remove item from cart
obj.removeItemFromCart = function(product_id) {
"use strict";
for(var item in cart) {
if(cart[item].product_id === product_id) {
cart[item].count --;
if(cart[item].count === 0) {
cart.splice(item, 1);
}
break;
}
}
saveCart();
}
// Clear cart
obj.clearCart = function() {
"use strict";
cart = [];
saveCart();
}
// Count cart
obj.totalCount = function() {
"use strict";
var totalCount = 0;
for(var item in cart) {
totalCount += cart[item].count;
}
return totalCount;
}
// Total cart
obj.totalCart = function() {
"use strict";
var totalCart = 0;
for(var item in cart) {
totalCart += cart[item].price * cart[item].count;
}
return Number(totalCart.toFixed(2));
}
// List cart
obj.listCart = function() {
var cartCopy = [];
for(i in cart) {
item = cart[i];
itemCopy = {};
for(p in item) {
itemCopy[p] = item[p];
}
itemCopy.total = Number(item.price * item.count).toFixed(2);
cartCopy.push(itemCopy)
}
return cartCopy;
}
// cart : Array
// Item : Object/Class
// addItemToCart : Function
// removeItemFromCart : Function
// removeItemFromCartAll : Function
// clearCart : Function
// countCart : Function
// totalCart : Function
// listCart : Function
// saveCart : Function
// loadCart : Function
return obj;
})();
// *****************************************
// Triggers / Events
// *****************************************
// Add item
$('.add-to-cart').on("click", function(event){
"use strict";
event.preventDefault();
var product_id = $(this).data('product_id');
var name = $(this).data('name');
var price = Number($(this).data('price'));
var pimage = $(this).data('pimage');
shoppingCart.addItemToCart(product_id, name, price, pimage, 1);
displayCart();
});
// Clear items
$('.clear-cart').on("click",function() {
"use strict";
shoppingCart.clearCart();
displayCart();
});
function displayCart() {
"use strict";
var cartArray = shoppingCart.listCart();
var output = "";
var total_order = 0;
for(var i in cartArray) {
total_order++;
output += "<div class='col-12'>"
+ "<div class='row justify-content-center'>"
+ "<div class='col-5'>"
+ "<div class='row'>"
+ "<div class='col-9 text-left'>"
+ "<img src='" + cartArray[i].pimage + "' class='rounded-circle' width='50' height='50' />"
+ "<span class='text-info pl-3 font-weight-bold'>" + cartArray[i].name + "</span>"
+ "</div>"
+ "<div class='col-3'>"
+ "<span class='text-dark pl-2 mr-1'>(" + cartArray[i].price + ")</span>"
+ "</div>"
+ "</div>"
+ "</div>"
+ "<div class='col-4'>"
+ "<div class='input-group'><button class='minus-item input-group-addon btn btn-primary'
data-product_id=" + cartArray[i].product_id + ">-</button>"
+ "<input type='number' class='item-count form-control' data-product_id='" +
cartArray[i].product_id + "' value='" + cartArray[i].count + "'>"
+ "<button class='plus-item btn btn-primary input-group-addon' data-product_id=" +
cartArray[i].product_id + ">+</button></div>"
+ "</div>"
+ "<div class='col-3'>"
+ "<button class='delete-item btn btn-danger' data-product_id=" + cartArray[i].product_id +
">X</button>"
+ "<span class='text-dart pl-2'><kbd>" + cartArray[i].total + "</kbd></span>"
+ "</div>"
+ "</div>"
+ "</div>"
+ "<div class='row' id='hedden-fields'><input type = 'hidden' class='sr-only'
name='ProductID[]' id='ProductName' value='" + cartArray[i].product_id + "'>"
+ "<input type = 'hidden' class='sr-only' name='ProductName[]' id='ProductName' value='" +
cartArray[i].name + "'>"
+ "<input type = 'hidden' class='sr-only' name='ProductPrice[]' id='ProductPrice' value='" +
cartArray[i].price + "'>"
+ "<input type = 'hidden' class='sr-only' name='ProductQuantity[]' id='ProductQuantity'
value='" + cartArray[i].count + "'>"
+ "<input type = 'hidden' class='sr-only' name='TotalOrderedItems' id='TotalOrderedItems'
value='" + total_order + "'></div>"
+ "<hr/>" ;
}
$('.show-cart').html(output);
$('.total-cart').html(shoppingCart.totalCart());
$('.total-count').html(shoppingCart.totalCount());
}
displayCart();
// =============================
// Cart toast display
// =============================
$('.show-toast').on("click",function(){
"use strict";
const x = document.getElementById("product-toast");
var item_name = $(this).data('name');
$("#item-name").text(item_name);
x.className = "show";
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
});
body {
padding-top: 80px;
}
.card-product .img-wrap {
border-radius: 3px 3px 0 0;
overflow: hidden;
position: relative;
height: 220px;
text-align: center;
}
.card-product .img-wrap img {
max-height: 100%;
max-width: 100%;
object-fit: cover;
}
.card-product .info-wrap {
overflow: hidden;
padding: 15px;
border-top: 1px solid #eee;
}
.card-product .bottom-wrap {
padding: 15px;
border-top: 1px solid #eee;
}
.label-rating { margin-right:10px;
color: #333;
display: inline-block;
vertical-align: middle;
}
.card-product .price-old {
color: #999;
}
.fa-2x-cart{
font-size:24px
}
.fa-shopping-cart {
margin-top: 0.2em;
position: relative;
}
.badge {
font-size: .25em;
display: block;
position: absolute;
top: -.70em;
right: -.70em;
width: 2.5em;
height: 2.4em;
line-height: 2em;
border-radius: 50%;
text-align: center;
color: #fff;
background: rgba(207, 0, 15, 1);
}
.zoom:hover {
transform: scale(1.05);
}
.zoom-sm:hover {
transform: scale(1.03);
}
float: left;
padding-top: 16px;
padding-bottom: 16px;
box-sizing: border-box;
background-color: #111;
color: #fff;
}
#product-toast #desc{
color: #fff;
padding: 16px;
overflow: hidden;
white-space: nowrap;
}
#product-toast.show {
visibility: visible;
-webkit-animation: fadein 0.5s, expand 0.5s 0.5s,stay 3s 1s, shrink 0.5s 2s, fadeout 0.5s 2.5s;
animation: fadein 0.5s, expand 0.5s 0.5s,stay 3s 1s, shrink 0.5s 4s, fadeout 0.5s 4.5s;
}
@-webkit-keyframes fadein {
from {bottom: 0; opacity: 0;}
to {bottom: 30px; opacity: 1;}
}
@keyframes fadein {
from {bottom: 0; opacity: 0;}
to {bottom: 30px; opacity: 1;}
}
@-webkit-keyframes expand {
from {min-width: 50px}
to {min-width: 350px}
}
@keyframes expand {
from {min-width: 50px}
to {min-width: 350px}
}
@-webkit-keyframes stay {
from {min-width: 350px}
to {min-width: 350px}
}
@keyframes stay {
from {min-width: 350px}
to {min-width: 350px}
}
@-webkit-keyframes shrink {
from {min-width: 350px;}
to {min-width: 50px;}
}
@keyframes shrink {
from {min-width: 350px;}
to {min-width: 50px;}
}
@-webkit-keyframes fadeout {
from {bottom: 30px; opacity: 1;}
to {bottom: 60px; opacity: 0;}
}
@keyframes fadeout {
from {bottom: 30px; opacity: 1;}
to {bottom: 60px; opacity: 0;}
}
top_items_count.innerHTML = count;
bottom_items_count.innerHTML = count;
function openBucket() {
bucket.visibility = "visible";
bucket.opacity = "1";
bucket.zIndex = "9";
bucket.transition = "all 0.5s";
}
exit.addEventListener('click', () => {
bucket.visibility = "hidden";
bucket.opacity = "0";
bucket.zIndex = "-9";
bucket.transition = "all 0.5s";
});
() => {
if (localStorage.food_cart) {
food_cart = JSON.parse(localStorage.food_cart);
showCart();
}
var qty=1;
var itemArray = {
Product: itemName,
Price: price,
Qty: qty
}
food_cart.push(itemArray)
saveCart();
showCart();
}
function saveCart() {
if (window.localStorage) {
localStorage.food_cart = JSON.stringify(food_cart);
}
}
function deleteItem(index) {
food_cart.splice(index, 1);
showCart();
saveCart();
}
function showCart() {
if (food_cart.length == 0) {
var _ul = document.querySelector('#ul');
_ul.innerHTML = "";
return;
}
// function expression
// Anonymous function
myfun1();
myfun2();
myfun3();
Output
It is a Function Expression
It is an Anonymous Function
It is an Arrow Function
ES6 Promises
A Promise represents something that is eventually fulfilled. A Promise can either be
rejected or resolved based on the operation outcome.
Callback
A Callback is a way to handle the function execution after the completion of the
execution of another function.
Syntax
Example
Output
JavaScript Async/Await
JavaScript is always synchronous and single-threaded that provides the event loops. The event loops
enable us to queue up an activity. This activity will not happen until the loops become available after
the program that queued the action has completed the execution. However, our program contains a
large number of functionalities, which causes our code to be asynchronous. The Async/Await
functionality is one of them. Async/Await is an extension of promises that we get as language
support.
1. <!DOCTYPE html>
2. <html>
3. <head>
4. <meta charset="utf-8">
5. <title>JavaScript Async</title>
6. </head>
7. <body>
8. <h2>JavaScript Async</h2>
9. <p id="main"></p>
10. <script>
11. function myDisplayer(some) {
12. document.getElementById("main").innerHTML = some;
13. }
14. async function myfirstFunction() {
15. return "Hello World!!!";
16. }
17. myfirstFunction().then(
18. function(value) {myDisplayer(value);},
19. function(error) {myDisplayer(error);}
20. );
21. </script>
22. </body>
23. </html>
Output: After executing the above code, we will get the output shown below in the
screenshot.
JavaScript Await
JavaScript Await function is used to wait for the promise. It could only be used inside the
async block. It instructs the code to wait until the promise returns a response. It only delays
the async block. Await is a simple command that instructs JavaScript to wait for an
asynchronous action to complete before continuing with the feature. It's similar to
a "pause until done" keyword. The await keyword is used to retrieve a value from a
function where we will usually be used the then() function. Instead of calling after the
asynchronous function, we'd use await to allocate a variable to the result and then use the
result in the code as we will in the synchronous code.
1. <!DOCTYPE html>
2. <html>
3. <head>
4. <meta charset="utf-8">
5. <title>JavaScript Await</title>
6. </head>
7. <body>
8. <h2>JavaScript Await</h2>
9. <p id="main"></p>
10. <script>
11. async function myDisplay() {
12. let myPromise = new Promise(function(myResolve, myReject) {
13. myResolve("Hello World!!");
14. });
15. document.getElementById("main").innerHTML = await myPromise;
16. }
17. myDisplay();
18. </script>
19. </body>
20.</html>
Output: After executing this code, we will get the output as shown below in the
screenshot:
Implementan application for reading the weather information from openweathermap.org and display
the information in the form of a graph on the web page.
MainPage.html
<!DOCTYPE html>
<html>
<head>
<title>Weather Report</title>
<link rel="icon" href="favicon.png">
<link rel="stylesheet" href="PageStyle.css">
<link href=
'https://fonts.googleapis.com/css?family=Delius Swash Caps'
rel='stylesheet'>
</head>
<body>
<p id="data" class="styleIt"></p>
<script src="JSPage.js"></script>
</body>
</html>
PageStyle.css
p.styleIt{
background-color: rgb(182, 182, 182);
border: 2px solid rgb(182, 182, 182);
border-radius: 8px;
text-align: center;
box-shadow: 6px 5px 2px rgb(182, 182, 182), 0 0 25px rgb(0, 0, 0), 0 0
5px rgb(182, 182, 182);
font-family: 'Delius Swash Caps';
}
body{
background:rgb(120, 120, 120);
margin: 0;
position: absolute;
top: 50%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%)
}
JSPage.js
var data =
document.getElementById("dat
a");
var Latitude;
var Longitude;
var key = "------Put Your Own Key----- ";
var url =
"http://api.openweathermap.org/data/2.5/weather?";
function getLocation(){
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(showPosition);
}
else{
data_of_Lat_Lon.innerHTML="Geolocation is not
supported by this browser. SORRY!";
}
}
function showPosition(position){
Latitude = position.coords.latitude;
Longitude = position.coords.longitude;
getData(Latitude,Longitude);
}
function getData(Lat,Lon){
const readyToSent =
(url+"lat="+Lat+"&lon="+Lon+"&appid="+key);
fetch(readyToSent)
.then(response=>response.json())
.then(data=>{
console.log(data);
fetchData(data)
})
}
function fetchData(data){
const icon =
"http://openweathermap.org/img/wn/"+data.weather[0].icon+"
@2x.png"
document.getElementById("data").innerHTML =
"<b>The weather report of your Location is :-
</b><br>"+
"<img src="+icon+"><br>"+
"<b>Country :</b>"+data.sys.country+
"<br><b>Local Area Name :</b>"+data.name+
"<br><b>Temp. :</b>"+parseFloat((data.main.temp -
273.15)).toFixed(1)+"℃"+
"<br><b>But You will feel like
:</b>"+parseFloat((data.main.feels_like -
273.15)).toFixed(1)+"℃"+
"<br><b>Min. Temp.
:</b>"+parseFloat((data.main.temp_min -
273.15)).toFixed(1)+"℃"+
"<br><b>Max. Temp.
:</b>"+parseFloat((data.main.temp_max -
273.15)).toFixed(1)+"℃"+
"<br><b>Pressure :</b>"+data.main.pressure+"hPa"+
"<br><b>Humidity :</b>"+data.main.humidity+"%"+
"<br><b>Weather
:</b>"+data.weather[0].description+
"<br>"
}
getLocation();
showPosition();
getData();
To create a Django application that performs CRUD operations, follow the following
steps.
1. Create a Project
2. Create an App
3. Project Structure
4. Database Setup
Create a database djangodb in mysql, and configure into the settings.py file of
django project. See the example.
// settings.py
1. DATABASES = {
2. 'default': {
3. 'ENGINE': 'django.db.backends.mysql',
4. 'NAME': 'djangodb',
5. 'USER':'root',
6. 'PASSWORD':'mysql',
7. 'HOST':'localhost',
8. 'PORT':'3306'
9. }
10. }
5. Create a Model
// models.py
6. Create a ModelForm
// forms.py
8. Provide Routing
// urls.py
1. from django.contrib import admin
2. from django.urls import path
3. from employee import views
4. urlpatterns = [
5. path('admin/', admin.site.urls),
6. path('emp', views.emp),
7. path('show',views.show),
8. path('edit/<int:id>', views.edit),
9. path('update/<int:id>', views.update),
10. path('delete/<int:id>', views.destroy),
11. ]
9. Organize Templates
Create a templates folder inside the employee app and create three (index, edit,
show) html files inside the directory. The code for each is given below
// index.html
1. <!DOCTYPE html>
2. <html lang="en">
3. <head>
4. <meta charset="UTF-8">
5. <title>Index</title>
6. {% load staticfiles %}
7. <link rel="stylesheet" href="{% static 'css/style.css' %}"/>
8. </head>
9. <body>
10. <form method="POST" class="post-form" action="/emp">
11. {% csrf_token %}
12. <div class="container">
13. <br>
14. <div class="form-group row">
15. <label class="col-sm-1 col-form-label"></label>
16. <div class="col-sm-4">
17. <h3>Enter Details</h3>
18. </div>
19. </div>
20. <div class="form-group row">
21. <label class="col-sm-2 col-form-label">Employee Id:</label>
22. <div class="col-sm-4">
23. {{ form.eid }}
24. </div>
25. </div>
26. <div class="form-group row">
27. <label class="col-sm-2 col-form-label">Employee Name:</label>
28. <div class="col-sm-4">
29. {{ form.ename }}
30. </div>
31. </div>
32. <div class="form-group row">
33. <label class="col-sm-2 col-form-label">Employee Email:</label>
34. <div class="col-sm-4">
35. {{ form.eemail }}
36. </div>
37. </div>
38. <div class="form-group row">
39. <label class="col-sm-2 col-form-label">Employee Contact:</label>
40. <div class="col-sm-4">
41. {{ form.econtact }}
42. </div>
43. </div>
44. <div class="form-group row">
45. <label class="col-sm-1 col-form-label"></label>
46. <div class="col-sm-4">
47. <button type="submit" class="btn btn-primary">Submit</button>
48. </div>
49. </div>
50. </div>
51. </form>
52. </body>
53. </html>
// show.html
1. <!DOCTYPE html>
2. <html lang="en">
3. <head>
4. <meta charset="UTF-8">
5. <title>Employee Records</title>
6. {% load staticfiles %}
7. <link rel="stylesheet" href="{% static 'css/style.css' %}"/>
8. </head>
9. <body>
10. <table class="table table-striped table-bordered table-sm">
11. <thead class="thead-dark">
12. <tr>
13. <th>Employee ID</th>
14. <th>Employee Name</th>
15. <th>Employee Email</th>
16. <th>Employee Contact</th>
17. <th>Actions</th>
18. </tr>
19. </thead>
20. <tbody>
21. {% for employee in employees %}
22. <tr>
23. <td>{{ employee.eid }}</td>
24. <td>{{ employee.ename }}</td>
25. <td>{{ employee.eemail }}</td>
26. <td>{{ employee.econtact }}</td>
27. <td>
28. <a href="/edit/{{ employee.id }}"><span class="glyphicon glyphicon-
pencil" >Edit</span></a>
29. <a href="/delete/{{ employee.id }}">Delete</a>
30. </td>
31. </tr>
32. {% endfor %}
33. </tbody>
34. </table>
35. <br>
36. <br>
37. <center><a href="/emp" class="btn btn-
primary">Add New Record</a></center>
38. </body>
39. </html>
// edit.html
1. <!DOCTYPE html>
2. <html lang="en">
3. <head>
4. <meta charset="UTF-8">
5. <title>Index</title>
6. {% load staticfiles %}
7. <link rel="stylesheet" href="{% static 'css/style.css' %}"/>
8. </head>
9. <body>
10. <form method="POST" class="post-
form" action="/update/{{employee.id}}">
11. {% csrf_token %}
12. <div class="container">
13. <br>
14. <div class="form-group row">
15. <label class="col-sm-1 col-form-label"></label>
16. <div class="col-sm-4">
17. <h3>Update Details</h3>
18. </div>
19. </div>
20. <div class="form-group row">
21. <label class="col-sm-2 col-form-label">Employee Id:</label>
22. <div class="col-sm-4">
23. <input type="text" name="eid" id="id_eid" required maxlength="20" va
lue="{{ employee.eid }}"/>
24. </div>
25. </div>
26. <div class="form-group row">
27. <label class="col-sm-2 col-form-label">Employee Name:</label>
28. <div class="col-sm-4">
29. <input type="text" name="ename" id="id_ename" required maxlength
="100" value="{{ employee.ename }}" />
30. </div>
31. </div>
32. <div class="form-group row">
33. <label class="col-sm-2 col-form-label">Employee Email:</label>
34. <div class="col-sm-4">
35. <input type="email" name="eemail" id="id_eemail" required maxlength
="254" value="{{ employee.eemail }}" />
36. </div>
37. </div>
38. <div class="form-group row">
39. <label class="col-sm-2 col-form-label">Employee Contact:</label>
40. <div class="col-sm-4">
41. <input type="text" name="econtact" id="id_econtact" required maxlen
gth="15" value="{{ employee.econtact }}" />
42. </div>
43. </div>
44. <div class="form-group row">
45. <label class="col-sm-1 col-form-label"></label>
46. <div class="col-sm-4">
47. <button type="submit" class="btn btn-success">Update</button>
48. </div>
49. </div>
50. </div>
51. </form>
52. </body>
53. </html>
Create migrations for the created model employee, use the following command.
After migrations, execute one more command to reflect the migration into the
database. But before it, mention name of app (employee) in INSTALLED_APPS of
settings.py file.
// settings.py
1. INSTALLED_APPS = [
2. 'django.contrib.admin',
3. 'django.contrib.auth',
4. 'django.contrib.contenttypes',
5. 'django.contrib.sessions',
6. 'django.contrib.messages',
7. 'django.contrib.staticfiles',
8. 'employee'
9. ]
Now, our application has successfully connected and created tables in database. It
creates 10 default tables for handling project (session, authentication etc) and one
table of our model that we created.
Adding Record
Click on the Add New Record button and fill the details. See the example.
Filling the details.
6. Create an xml for the bookstore. Validate the same using both DTD and
XSD
< booksinfor.dtd >
<!ELEMENT books (book+)>
<!ELEMENT book (title,author,ISBN,publisher,edition,price)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT ISBN (#PCDATA)>
<!ELEMENT publisher (#PCDATA)>
<!ELEMENT edition (#PCDATA)>
<!ELEMENT price (#PCDATA)>
Mysql database
Procedure:
Reg.html:
<html>
<head>
<title> validation </title>
</head>
<body bgcolor="magenta">
<form action="Register.jsp" method="post">
<h1 align="center">REGISTRATION FORM</h1>
<table border="0">
<tr>
<td>Name:</td>
<td><input type="text" name="t1" min length="6"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="t2"></td>
</tr>
<tr>
<td>Phone number:</td>
<td><input type="text" name="t3"></td>
</tr>
<tr>
<td>E-mail id:</td>
<td><input type="text" name="t4"></td>
</tr>
<tr>
<td><input type="submit" value="submit"></td>
<td><input type="reset" value="cancel"></td>
</tr>
</table>
</form>
</body>
</html>
Register.jsp:
<%@ page language="java" import="java.sql.*,javax.servlet.*" %>
<html>
<form >
<%
String v1,v2,v3,v4,str;
v1=request.getParameter("t1");
v2=request.getParameter("t2");
v3=request.getParameter("t3");
v4=request.getParameter("t4");
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection cn=DriverManager.getConnection("jdbc:odbc:oradsn","system","ravindra");
Statement st=cn.createStatement();
st.executeUpdate("insert into register values('"+v1+"','"+v2+"',"+v3+",'"+v4+"')");
if(cn!=null)
{
%>
</form>
Registration Successful
<%
}
else
{
out.println("Registration failed");
}
st.close();
cn.close();
}catch(Exception e) { out.println(" Registration failed");
%>
<P><a href = "reg.html" target =f2 ><B> Back<B></a>
<%
}
%>
</body></html>
Execution:
Create a table with name register with name (varchar2 (10)), password (varchar2 (10)),
Phone(number (10)) ,Email-ID (varchar2(10)).
Create the Data source name.
Start->settings->control panel->Administrative Tools->Data Sources.
Under SystemDSN add Microsoft ODBC for Oracle.
Set Data Source name to oradsn.
Output:1
Output:2
8. Maintaining the transactional history of any user is very important. Explore the
various sessiontracking mechanism (Cookies, HTTP Session)
package com.journaldev.servlet.session;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* Servlet implementation class LoginServlet
*/
@WebServlet("/LoginServlet")
public class LoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private final String userID = "admin";
private final String password = "password";
package com.journaldev.servlet.session;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* Servlet implementation class LogoutServlet
*/
@WebServlet("/LogoutServlet")
public class LogoutServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
}
elseif (req.url == "/student") {
}
else
res.end('Invalid Request!');
});
To test it, you can use the command-line program curl, which most Mac and Linux
machines have pre-installed.
curl -i http://localhost:5000
HTTP/1.1 200 OK
Content-Type: text/plain
Connection: keep-alive
10. Develop an express web application that can interact with REST API to perform 14
CRUDoperations on student data. (Use Postman)
#1) Installations.
Installation Required
Create a new folder (at the place you want to keep your project).
Name that folder: node-ex-api
After creating above two files, open your terminal in the "node-ex-
api" folder and run this command:
npm install
To test this API — Open your web browser and enter this URL
→ localhost:3000
We have tested the GET methods of our API in our web browser
(check #4) and seen responses. But we can’t test POST, PUT and
DELETE http methods in web browser. To test those methods we
use Postman or you may use another http utility to call APIs.
Here we use Postman. So before start click here and install
Postman.
After Postman installation skip start window (if comes), then login
with Google or email/password (whichever you prefer) and finally
you must see this screen:
11. For the above application create authorized end points using JWT (JSON Web Token).
Our default endpoint returns string — we see that above. Now we’ll
create another API endpoint, that is another URL which returns
some useful data.
Before proceed, let’s do some more exercise:
→ Create a folder inside the project root with name "routes".
→ Then create a file inside this "routes" folder with
name "items.js".
module.exports = router;
🌞 See below ↓↓
🌞 See below ↓↓
Now, run npm start if your server is not running. This time we have
three end-points:
→ localhost:3000 (Default)
→ localhost:3000/items (Returns all objects)
→ localhost:3000/items/1 (Returns single object of id=1)
Click image )
' If you can’t see this.
’
12. Create a react application for the student management system having registration, login,
contact, about pages and implement routing to navigate through these pages.
app.use(express.urlencoded({extended:true}));
app.use(express.json());
app.use(cors());
app.get("/api",(req,res)=>{
res.json({message:"Hello world"});
});
app.listen(PORT,()=>{
console.log(`Server listening on ${PORT}`);
});
In this section, we'll build the user interface for the application
allowing users to register and sign in to an application. Users can
create an account, log in, and perform 2FA via SMS before they are
authorised to view the dashboard.
Delete the redundant files such as the logo and the test files from
the React app, and update the App.js file to display Hello World as
below.
functionApp(){
return(
<div>
<p>Hello World!</p>
</div>
);
}
exportdefaultApp;
Navigate into the src/index.css file and copy the code below. It
contains all the CSS required for styling this project.
@importurl("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;40
0;500;600;700&display=swap");
*{
box-sizing:border-box;
margin:0;
padding:0;
font-family:"Space Grotesk",sans-serif;
}
input{
height:45px;
padding:10px15px;
margin-bottom:15px;
}
button{
width:200px;
outline:none;
border:none;
padding:15px;
cursor:pointer;
font-size:16px;
}
.login container,
.signup container,
.verify,
.dashboard{
width:100%;
min-height:100vh;
padding:50px70px;
display:flex;
flex-direction:column;
align-items:center;
justify-content:center;
}
.login form,
.verify form,
.signup form{
width:100%;
display:flex;
flex-direction:column;
}
.loginBtn,
.signupBtn,
.codeBtn{
background-color:green;
color:#fff;
margin-bottom:15px;
}
.signOutBtn{
background-color:#c21010;
color:#fff;
}
.link{
cursor:pointer;
color:rgb(39,147,39);
}
.code{
width:50%;
text-align:center;
}
.verify form{ align-
items:center;
}
@mediascreenand(max-width:800px){
.login container,
.signup container,
.verify{
padding:30px;
}
}
functionApp(){
return(
<BrowserRouter>
<Routes>
<Routepath='/'element={<Login/>}/>
<Routepath='/register'element={<Signup/>}/>
<Routepath='/dashboard'element={<Dashboard/>}/>
<Routepath='phone/verify'element={<PhoneVerify/>}/>
</Routes>
</BrowserRouter>
);
}
exportdefaultApp;
The Login page
Copy the code below into the Login.js file. It accepts the email and
password from the user.
importReact,{useState}from"react";
import{useNavigate}from"react-router-dom";
constLogin=()=>{
const[email,setEmail]=useState("");
const[password,setPassword]=useState("");
constnavigate=useNavigate();
consthandleSubmit=(e)=>{
e.preventDefault();
console.log({email,password});
setPassword("");
setEmail("");
};
constgotoSignUpPage=()=>navigate("/register");
return(
<divclassName='login container'>
<h2>Login </h2>
<formclassName='login form'onSubmit={handleSubmit}>
<labelhtmlFor='email'>Email</label>
<input
type='text'
id='email'
name='email'
value={email}
required
onChange={(e)=>setEmail(e.target.value)}
/>
<labelhtmlFor='password'>Password</label>
<input
type='password'
name='password'
id='password'
minLength={8}
required
value={password}
onChange={(e)=>setPassword(e.target.value)}
/>
<buttonclassName='loginBtn'>SIGN IN</button>
<p>
Don't have an account?{""}
<spanclassName='link'onClick={gotoSignUpPage}>
Sign up
</span>
</p>
</form>
</div>
);
};
exportdefaultLogin;
Copy the code below into the Signup.js file. It accepts the email,
username, telephone, and password from the user.
importReact,{useState}from"react";
import{useNavigate}from"react-router-dom";
constSignup=()=>{
const[email,setEmail]=useState("");
const[username,setUsername]=useState("");
const[tel,setTel]=useState("");
const[password,setPassword]=useState("");
constnavigate=useNavigate();
consthandleSubmit=(e)=>{
e.preventDefault();
console.log({email,username,tel,password});
setEmail("");
setTel("");
setUsername("");
setPassword("");
};
constgotoLoginPage=()=>navigate("/");
return(
<divclassName='signup container'>
<h2>Sign up </h2>
<formclassName='signup form'onSubmit={handleSubmit}>
<labelhtmlFor='email'>Email Address</label>
<input
type='email'
name='email'
id='email'
value={email}
required
onChange={(e)=>setEmail(e.target.value)}
/>
<labelhtmlFor='username'>Username</label>
<input
type='text'
id='username'
name='username'
value={username}
required
onChange={(e)=>setUsername(e.target.value)}
/>
<labelhtmlFor='tel'>Phone Number</label>
<input
type='tel'
name='tel'
id='tel'
value={tel}
required
onChange={(e)=>setTel(e.target.value)}
/>
<labelhtmlFor='tel'>Password</label>
<input
type='password'
name='password'
id='password'
minLength={8}
required
value={password}
onChange={(e)=>setPassword(e.target.value)}
/>
<buttonclassName='signupBtn'>SIGN UP</button>
<p>
Already have an account?{""}
<spanclassName='link'onClick={gotoLoginPage}>
Login
</span>
</p>
</form>
</div>
);
};
exportdefaultSignup;
13. Create a service in react that fetches the weather information from openweathermap.org
and the display the current and historical weather information using graphical representation
usingchart.js
//PAGE LOAD//
//*** GET SAVED ITEMS FROM LOCAL STORAGE ***//
let savedSearchArray =
JSON.parse(localStorage.getItem('savedSearchArray'));
if (!savedSearchArray) {
savedSearchArray = [
'Columbus',
'Bend',
'Los Angeles',
'San Francisco',
'Savannah',
'New York',
'Nashville'
];
}
fetch(currentWeatherUrl).then(function (response) {
if (response.ok) {
response.json().then(function (data) {
console.log(data)
//define function to get 5 day forecast //access lat and lon from previous
function
//use one call API instead of 5 day forecast //better accessibility to needed
information
function getForecast(latitude, longitude) {
const forecastUrl =
'https://api.openweathermap.org/data/2.5/onecall?lat=' + latitude +
'&lon=' + longitude +
'&units=imperial&exclude=hourly,minutely&appid=c6a9bf78cf3b504fe7
e8382ca53765c4';
fetch(forecastUrl).then(function (response) {
if (response.ok) {
response.json().then(function (data) {
console.log(data)
//description forecast
//TODO: for loop
const desc1 = document.querySelector('#desc_1');
desc1.innerHTML = (data.daily[1].weather[0].main);
const desc2 = document.querySelector('#desc_2');
desc2.innerHTML = (data.daily[2].weather[0].main);
const desc3 = document.querySelector('#desc_3');
desc3.innerHTML = (data.daily[3].weather[0].main);
const desc4 = document.querySelector('#desc_4');
desc4.innerHTML = (data.daily[4].weather[0].main);
const desc5 = document.querySelector('#desc_5');
desc5.innerHTML = (data.daily[5].weather[0].main);
//temp forecast
//TODO for loop
// for (i = 0; i < forecast.length; i++)
const temp1 = document.querySelector('#temp_1');
temp1.innerHTML = Math.round(data.daily[1].temp.day) +
`º`;
const temp2 = document.querySelector('#temp_2');
temp2.innerHTML = Math.round(data.daily[2].temp.day) +
`º`;
const temp3 = document.querySelector('#temp_3');
temp3.innerHTML = Math.round(data.daily[3].temp.day) +
`º`;
const temp4 = document.querySelector('#temp_4');
temp4.innerHTML = Math.round(data.daily[4].temp.day) +
`º`;
const temp5 = document.querySelector('#temp_5');
temp5.innerHTML = Math.round(data.daily[5].temp.day) +
`º`;
//humidity forecast
//TODO for loop
// for (i = 0; i < forecast.length; i++)
const humid1 = document.querySelector('#humid_1');
humid1.innerHTML = (data.daily[1].humidity) + `%`;
const humid2 = document.querySelector('#humid_2');
humid2.innerHTML = (data.daily[2].humidity) + `%`;
const humid3 = document.querySelector('#humid_3');
humid3.innerHTML = (data.daily[3].humidity) + `%`;
const humid4 = document.querySelector('#humid_4');
humid4.innerHTML = (data.daily[4].humidity) + `%`;
const humid5 = document.querySelector('#humid_5');
humid5.innerHTML = (data.daily[5].humidity) + `%`;
})
}
})
};
//select each search history list item
const searchHistCon = document.querySelector('#search-history-list')
const searchedItemEl = searchHistCon.querySelectorAll('li.search-
history-item');
console.log(searchedItemEl);
})
}
}
getCurrent(userInput);
localStorage.setItem('savedSearchArray',
JSON.stringify(savedSearchArray));
});
searchHistoryMenuLi.addEventListener('click', renderSearchHistory());
getCurrent('Columbus');
Whether.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min
.css" rel="stylesheet" integrity="sha384-
EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65Vohh
puuCOmLASjC" crossorigin="anonymous">
<link rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.8.1/css/all.css"
integrity="sha384-
50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIeb
hndOJK28anvf" crossorigin="anonymous" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link
href="https://fonts.googleapis.com/css2?family=Josefin+Sans:ital,wght@
0,100;0,200;0,300;0,400;0,500;1,100;1,200;1,300;1,400&family=Montse
rrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,
100;1,200;1,300&family=Noto+Sans:ital,wght@0,100;0,200;0,300;0,400
;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300&family=Poppins:ital,
wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,2
00;1,300&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,90
0;1,100;1,300;1,400&family=Rubik+80s+Fade&family=Source+Sans+Pr
o:wght@300&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/reset.css" />
<link rel="stylesheet" href="assets/css/style.css" />
<link rel="stylesheet" href="assets/css/responsive.css" />
<title>Current Weather</title>
</head>
<body>
<div class="navbar">
<!-- Dropdown menu -->
<nav class="btn-group dropend">
<button type="button" class="btn dropdown-toggle" data-bs-
toggle="dropdown" aria-expanded="false"></button>
<ul class="dropdown-menu" id="popout-menu">
<div class="hidden">
<div class="" id="current-humid"></div>
<div class="" id="current_wind">Wind Speed: </div>
<div class="" id="current_uv">UV Index: </div>
</div>
</div>
<div class="forecast-card">
</div>
<div class="forecast-card">
<div class="forecast-card">
</div>
<div class="forecast-card">
</div>
<div class="forecast-card">
</div>
</div>
<div class="text-muted container" id="city-name">Search a City</div>
</main>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundl
e.min.js" integrity="sha384-
MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+J
cXn/tWtIaxVXM" crossorigin="anonymous"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></
script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min
.js"></script>
<script src="assets/script.js"></script>
</body>
</html>
<!DOCTYPE
html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on
a
user's mobile device or desktop. See
https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the
build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run
build`.
-->
<title>Todo List</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
App.js file:-
importReactfrom"react";
import"./App.css";
import { Button, Card, Form } from'react-bootstrap';
import'bootstrap/dist/css/bootstrap.min.css';
functionFormTodo({ addTodo }) {
const [value, setValue] =React.useState("");
consthandleSubmit= e => {
e.preventDefault();
if (!value) return;
addTodo(value);
setValue("");
};
return (
<FormonSubmit={handleSubmit}>
<Form.Group>
<Form.Label><b>Add Todo</b></Form.Label>
<Form.Controltype="text"className="input"value={value}
onChange={e => setValue(e.target.value)} placeholder="Add new
todo"/>
</Form.Group>
<Buttonvariant="primary mb-3"type="submit">
Submit
</Button>
</Form>
);
}
functionApp() {
const [todos, setTodos] =React.useState([
{
text: "This is a sampe todo",
isDone: false
}
]);
return (
<divclassName="app">
<divclassName="container">
<h1className="text-center mb-4">Todo List</h1>
<FormTodoaddTodo={addTodo} />
<div>
{todos.map((todo, index) => (
<Card>
<Card.Body>
<Todo
key={index}
index={index}
todo={todo}
markTodo={markTodo}
removeTodo={removeTodo}
/>
</Card.Body>
</Card>
))}
</div>
</div>
</div>
);
}
exportdefaultApp;