Web Development Course: Node, React, Django
Web Development Course: Node, React, Django
Course Objectives:
● To implement the static web pages using HTML and do client side validation using
JavaScript.
Course Outcomes:
At the end of the course, the student will be able toBuild a custom website with HTML, CSS,
and Bootstrap and little JavaScript.
Use JavaScript for doing client – side validation of the pages implemented
3.
in the experiment
Explore the features of ES6 like arrow functions, callbacks, promises,
async/await. Implement an application for reading the weather
4.
information from [Link] and display the information in the
form of a graph on the web page.
Develop a java stand alone application that connects with the database
5.
(Oracle / mySql) and perform the CRUD operation on the database tables.
Create an xml for the bookstore. Validate the same using both DTD and
6.
XSD.
Design a controller with servlet that provides the interaction with application
7.
developed in experiment 1 and the database created in experiment 5.
Maintaining the transactional history of any user is very important. Explore the
8.
various session tracking mechanism (Cookies, HTTP Session).
Create a custom server using http module and explore the other modules
9.
of Node JS like OS, path, event.
Develop an express web application that can interact with REST API to
10.
perform CRUD operations on student data. (Use Postman)
For the above application create authorized end points using JWT (JSON Web
11.
Token).
Create a react application for the student management system having
12. registration, login, contact, about pages and implement routing to navigate
through these pages.
Create a service in react that fetches the weather information from open
13. [Link] and the display the current and historical weather
information using graphical representation using [Link]
Create a TODO application in react with necessary components and
14.
deploy it into github.
1. Aim:
Solution :
[Link]
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet"href="./[Link]">
<title>Home - FBS</title>
</head>
<body>
<div class="wrapper">
<div class="container">
<header>
<table
width="100%"align="center"cellpadding="0"cellspacing="2">
<tr>
<thwidth="20%"><imgsrc="[Link]"alt="FBS
LOGO"width="130"height="100"/></th>
<thcolspan=4>
<h1 style="color:white;">FBS - WORLD BEST ONLINE EBOOKS
WEBSITE</h1>
</th>
</tr>
</table>
</header>
<nav>
<table
width="100%"align="center"cellpadding="0"cellspacing="2">
<tbodyalign="center"style="font-weight:bold;font-size:18px;"">
<tr>
<td width="20%"><hr><a href="[Link]">Home</a><hr></td>
<td width="20%"><hr><a href="[Link]">Login</a><hr></td>
<td width="20%"><hr><a
href="[Link]">Registration</a><hr></td>
<td width="20%"><hr><a href="[Link]">Cart</a><hr></td>
</tr>
</tbody>
</table>
</nav>
</div>
<div class="container1">
<div class="sidebar1"></div>
<div class="container2">
<main>
<center>
<h2>Welcome to FBS e-Book's Website</h2>
<p>Shopping at <font size=5>FBS</font> can be both <font
size=5>fun</font>
and<font size=5>savings</font>.</br>Shop with us in this
special <font
size=5>discount</font> season and save upto<font
size=5>90%</font> on all your
purchases.</br></p>
<br/><br/><br/><br/><br/><br/><br/><br/>
</main>
</div>
<div class="sidebar2"></div>
</div>
<footer><font color="white">(C) 2024 All rights reserved by
FBS ebooks</font></footer>
</div>
</body>
</html>
[Link]
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet"href="./[Link]">
<title>Login - FBS</title>
</head>
<body>
<div class="wrapper">
<div class="container">
<header>
<table
width="100%"align="center"cellpadding="0"cellspacing="2">
<tr>
<thwidth="20%"><imgsrc="[Link]"alt="FBS
LOGO"width="130"height="100"/></th>
<thcolspan=4>
<h1 style="color:white;">FBS - WORLD BEST ONLINE EBOOKS
WEBSITE</h1>
</th>
</tr>
</table>
</header>
<nav>
<table
width="100%"align="center"cellpadding="0"cellspacing="2">
<tbodyalign="center"style="font-weight:bold;font-size:18px;"">
<tr>
<td width="20%"><hr><a href="[Link]">Home</a><hr></td>
<td width="20%"><hr><a href="[Link]">Login</a><hr></td>
<td width="20%"><hr><a
href="[Link]">Registration</a><hr></td>
<td width="20%"><hr><a href="[Link]">Cart</a><hr></td>
</tr>
</tbody>
</table>
</nav>
</div>
<div class="container1">
<div class="sidebar1"></div>
<div class="container2">
<main>
<center><br>
<h3> Login Details</h3><br/>
<form name="f1">
<table width="100%"align="center">
<tr>
<td> User Name : </td>
<td><input type="text"name="username"></td>
</tr>
<tr><td><br></td></tr>
<tr>
<td> Password : </td>
<td><input type="password"name="password"></td>
</tr>
<tr><td><br></td></tr>
<tr><td></td>
<td><input type="submit"value="SUBMIT">
<input type="reset"value="RESET"></td>
</tr>
</table>
</form>
</center>
</main>
</div>
<div class="sidebar2"></div>
</div>
<footer><font color="white">(C) 2024 All rights reserved by
FBS ebooks</font></footer>
</div>
</body>
</html>
[Link]
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet"href="./[Link]">
<title>Registration - FBS</title>
</head>
<body>
<div class="wrapper">
<div class="container">
<header>
<table
width="100%"align="center"cellpadding="0"cellspacing="2">
<tr>
<thwidth="20%"><imgsrc="[Link]"alt="FBS
LOGO"width="130"height="100"/></th>
<thcolspan=4>
<h1 style="color:white;">FBS - WORLD BEST ONLINE EBOOKS
WEBSITE</h1>
</th>
</tr>
</table>
</header>
<nav>
<table
width="100%"align="center"cellpadding="0"cellspacing="2">
<tbodyalign="center"style="font-weight:bold;font-size:18px;"">
<tr>
<td width="20%"><hr><a href="[Link]">Home</a><hr></td>
<td width="20%"><hr><a href="[Link]">Login</a><hr></td>
<td width="20%"><hr><a
href="[Link]">Registration</a><hr></td>
<td width="20%"><hr><a href="[Link]">Cart</a><hr></td>
</tr>
</tbody>
</table>
</nav>
</div>
<div class="container1">
<div class="sidebar1"></div>
<div class="container2">
<main>
<center><br>
<h3>Registration Form </h3>
<br/>
<form name="f1">
<table cellpadding="1"align="center">
<tr><td> Name:*</td>
<td><input type="text"name="username"></td></tr>
<tr><td>Password:*</td>
<td><input type="password"name="password"></td></tr>
<tr><td>Email ID:*</td>
<td><input type="text"name="email"></td></tr>
<tr><td>Phone Number:*</td>
<td><input type="text"name="phno"></td></tr>
<tr><td valign="top">Gender:*</td>
<td><input type="radio"name="radio"value="1">Male
<input type="radio"name="radio"value="2">Female</td></tr>
<tr><td valign="top">Language Known:*</td>
<td><input
type="checkbox"name="checkbox"value="English">English<br/>
<input type="checkbox"name="checkbox"value="Telugu">Telugu<br>
<input type="checkbox"name="checkbox"value="Hindi">Hindi<br>
<input type="checkbox"name="checkbox"value="Tamil">Tamil
</td></tr>
<tr><td valign="top">Address:*</td>
<td><textareaname="address"></textarea></td>
<tr><td></td><td><input
type="submit"value="submit"hspace="10">
<input type="reset"value="reset"></td></tr>
<tr><td colspan=2>*<font color="#FF0000">fields are
mandatory</font>
</td>
</tr>
</table>
</form>
</center>
</main>
</div>
<div class="sidebar2"></div>
</div>
<footer><font color="white">(C) 2024 All rights reserved by
FBS ebooks</font></footer>
</div>
</body>
</html>
[Link]
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet"href="./[Link]">
<title>Cart - FBS</title>
</head>
<body>
<div class="wrapper">
<div class="container">
<header>
<table
width="100%"align="center"cellpadding="0"cellspacing="2">
<tr>
<thwidth="20%"><imgsrc="[Link]"alt="FBS
LOGO"width="130"height="100"/></th>
<thcolspan=4>
<h1 style="color:white;">FBS - WORLD BEST ONLINE EBOOKS
WEBSITE</h1>
</th>
</tr>
</table>
</header>
<nav>
<table
width="100%"align="center"cellpadding="0"cellspacing="2">
<tbodyalign="center"style="font-weight:bold;font-size:18px;"">
<tr>
<td width="20%"><hr><a href="[Link]">Home</a><hr></td>
<td width="20%"><hr><a href="[Link]">Login</a><hr></td>
<td width="20%"><hr><a
href="[Link]">Registration</a><hr></td>
<td width="20%"><hr><a href="[Link]">Cart</a><hr></td>
</tr>
</tbody>
</table>
</nav>
</div>
<div class="container1">
<div class="sidebar1"></div>
<div class="container2">
<main>
<center>
<h3>Cart</h3>
<table width="100%"align="center">
<tbody>
<tr>
<thwidth="40%"><hr>BookName<hr></th>
<thwidth="20%"><hr>Price<hr></th>
<thwidth="20%"><hr>Quantity<hr></th>
<thwidth="20%"><hr>Amount<hr></th></tr>
</tbody>
<tbodyalign=center>
<tr><td>Java Programming </td>
<td>Rs. 2300/-</td>
<td>2</td>
<td>Rs. 4600/-</td></tr>
<tr><td>Web Technologies</td>
<td>Rs. 3000/-</td>
<td>1</td>
<td>Rs. 3000/-</td></tr>
<tr><td></td>
<td><hr><font color="#996600">Total Amount:</font><hr></td>
<td><hr>3<hr></td>
<td><hr>Rs. 7600/-<hr></td></tr>
</tbody>
</table>
</center>
</main>
</div>
<div class="sidebar2"></div>
</div>
<footer><font color="white">(C) 2024 All rights reserved by
FBS ebooks</font></footer>
</div>
</body>
</html>
[Link]
body{
font-family:monospace;
}
main{
background-color: #efefef;
color: #330000;
margin-left:10px;
height:60vh;
}
header, footer{
background-color: #000d57;
color: #fff;
padding:1rem;
height:50px;
}
header,nav{
margin-bottom:10px;
flex-basis:50%;
}
footer{
margin-top:10px;
}
nav{
background-color: #fff;
color: #000;
padding:1rem;
height:20px;
}
.sidebar1, .sidebar2{
flex-basis:10%;
background-color: #fff;
color: #000;
}
.sidebar2{
margin-left:10px;
}
.container1{
display: flex;
}
.container2{
display: flex;
flex-direction: column;
flex:1;
}
.wrapper{
display: flex;
flex-direction: column;
font-weight:600;
}
Output :
3. Aim:
Solution :
[Link]
<html>
<head>
<title> Welcome to NNRG e-Book's website</title>
<script language="javascript">
functionvalidate(){
// username validation
varuname= [Link];
if([Link]<=0)
{
alert("Please Enter UserName");
[Link]();
returnfalse;
}
if([Link]<8)
{
alert("Please enter UserName not less than 8");
[Link]();
returnfalse;
}
//password validation
varpwd= [Link];
if([Link]<=0)
{
alert("Please Enter password");
[Link]();
returnfalse;
}
if([Link]<6)
{
alert("Please enter Password not less than 6");
[Link]();
returnfalse;
}
// email validation
var email = [Link];
if([Link]<=0)
{
alert("Please Enter email");
[Link]();
returnfalse;
}
else{
leteflag=false;
for(i=0;i<[Link];i++){
if([Link](i)=="@")
{
eflag=true;
}
}
if(!(eflag))
{
alert("Please enter a valid Email ID");
[Link]();
returnfalse;
}
}
// phone number validation
varphno= [Link];
if([Link]<=0)
{
alert("Please Enter Phone Number");
[Link]();
returnfalse;
}
if(isNaN(phno))
{
alert("Please Enter Valid Phone Number");
[Link]();
returnfalse;
}
if([Link]!=10)
{
alert("Please Enter Valid Phone Number");
[Link]();
returnfalse;
}
// gender validation
let flag=false;
for(i=0;i<[Link];i++)
if([Link][i].checked)
flag=true;
if(!(flag))
{
alert("Please choose a Gender");
returnfalse;
}
// Language validation
flag=false;
for(i=0;i<[Link];i++)
if([Link][i].checked)
flag=true;
if(!(flag))
{
alert("Please select at least one of the Language options.");
returnfalse;
}
// address validation
varaddr= [Link];
if([Link]<=0)
{
alert("Please Enter address");
[Link]();
returnfalse;
}
// to display Success message
alert("Registration Successful");
}
</script>
</head>
<body>
<center><br>
<h3>Registration Form </h3>
<br/>
<form name="f1">
<table cellpadding="1"align="center">
<tr><td> User Name:*</td>
<td><input type="text"name="username"></td></tr>
<tr><td>Password:*</td>
<td><input type="password"name="password"></td></tr>
<tr><td>Email ID:*</td>
<td><input type="text"name="email"></td></tr>
<tr><td>Phone Number:*</td>
<td><input type="text"name="phno"></td></tr>
<tr><td valign="top">Gender:*</td>
<td><input type="radio"name="gen"value="Male">Male
<input type="radio"name="gen"value="Female">Female</td></tr>
<tr><td valign="top">Language Known:*</td>
<td><input
type="checkbox"name="lang"value="English">English<br/>
<input type="checkbox"name="lang"value="Telugu">Telugu<br>
<input type="checkbox"name="lang"value="Hindi">Hindi<br>
<input type="checkbox"name="lang"value="Tamil">Tamil
</td></tr>
<tr><td valign="top">Address:*</td>
<td><textareaname="address"></textarea></td>
<tr><td></td><td><input
type="button"value="SUBMIT"hspace="10"onclick="validate()">
<input type="reset"value="RESET"></td></tr>
<tr><td colspan=2>*<font color="#FF0000">fields are
mandatory</font>
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
Output :
4. Aim:
Solution :
Java Script Async
<!DOCTYPE html><html lang="en"><head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title>Document</title>
</head><body>
<h2>JavaScript Async</h2>
<p id="main"></p>
<script>function myDisplayer(some)
{
[Link]("main").innerHTML =
some;
}
async function myfirstFunction()
{
</script>
</body>
</html>
*********************************OUTPUT***************************************
});
[Link]("main").innerHTML
= await myPromise;
}
myDisplay();
</script>
</body>
</html>
***********************************OUTPUT***************************************
Implement an application for reading the weather information from [Link] and
display the information in the form of a graph on the web page.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title>Weather Information</title>
<style>/* CSS */
.weather-info { display: flex; flex-direction:
column;
align-items: center;justify-content: center;}
.icon { width: 150px; height: 150px;
}
.icon img {width: 100%;height: 100%;
}
</style>
</head>
<body style='background-color:#467'>
<!-- HTML -->
<div class="weather-info">
<h2>Weather in Hyderabad</h2>
<div class="icon">
<img src="" alt="weather icon">
</div>
<p class="temperature"></p>
<p class="description"></p>
</div>J <script>
API_KEY = '5eda0f8c6bbe529f634e390ff13af2ed';
const CITY = 'Hyderabad'
const WEATHER_API =
`[Link]
{CITY}&appid=${API_KEY}&units=metric`;
const weatherIcon =
[Link]('.icon img');const temperature =
[Link]('.temperature');const description =
[Link]('.description');fetch(WEATHER_API).t
hen(response => [Link]()).then(data =>
{
[Link](data);
const iconURL =
`[Link]
{[Link][0].icon}.png`;
[Link]('src', iconURL);
[Link] = `$
{[Link]}°C`;
[Link] =
[Link][0].description;
}
) .catch(error => [Link](error));
</script>
</body>
</html>
************************************OUTPUT*************************************
5. Aim:
import [Link].*;
import [Link];
[Link]("Enter Username:");
String uname=[Link]();
[Link]("Enter Password:");
String upass=[Link]();
String email=[Link]();
int mobno=[Link]();
[Link]("Enter Gender:");
String gen=[Link]();
String lang=[Link]();
String addr=[Link]();
try
[Link]("[Link]");
Connection
conn=[Link]("jdbc:oracle:thin:@localhost:1521:xe"
,"system","system");
Statement stmt=[Link]();
[Link]("Record inserted.");
catch(Exception e)
[Link](e);
****************OUTPUT*****************
Enter Username:
Hema
Enter Password:
Reddy
Hema@[Link]
Enter Gender:
Female
Hindi
HYD
Record inserted.
import [Link].*;
import [Link];
[Link]("Enter Username:");
String uname=[Link]();
[Link]("Enter Password:");
String upass=[Link]();
[Link]("Enter Email id:");
String email=[Link]();
int mobno=[Link]();
[Link]("Enter Gender:");
String gen=[Link]();
String lang=[Link]();
String addr=[Link]();
try
[Link]("[Link]");
Connection
conn=[Link]("jdbc:oracle:thin:@localhost:1521:xe"
,"system","system");
Statement stmt=[Link]();
[Link]("Record updated.");
catch(Exception e)
{
[Link](e);
******************OUTPUT*********************
run:
Enter Username:
Hema
Enter Password:
Reddy
hema@[Link]
939029510
Enter Gender:
Female
Hindi
NZB
Record updated.
import [Link];
[Link]("Enter Username:");
String uname=[Link]();
try
[Link]("[Link]");
Connection
conn=[Link]("jdbc:oracle:thin:@localhost:1521:xe"
,"system","system");
Statement stmt=[Link]();
[Link]("Record deleted.");
catch(Exception e)
[Link](e);
}
****************OUTPUT*****************
run:
Enter Username:
Hema
Record deleted.
import [Link].*;
import [Link].*;
try
[Link]("[Link]");
Connection
conn=[Link]("jdbc:oracle:thin:@localhost:1521:xe"
,"system","system");
Statement st=[Link]();
ResultSet rs=[Link]("select * from reg");
while([Link]())
String name=[Link]("uname");
String pass=[Link]("pass");
String email=[Link]("email");
int mobno=[Link]("mobno");
String gen=[Link]("gen");
String lang=[Link]("lang");
String addr=[Link]("addr");
[Link]("Employee Username:"+name);
[Link]("Employee Password:"+pass);
[Link]("Employee Gender:"+gen);
[Link]("Employee Language:"+lang);
[Link]("Employee Address:"+addr);
catch(Exception e)
{
[Link](e);
finally
[Link]();
***************OUTPUT*******************
run:
Employee Username:Seema
Employee Password:wadkar
Employee Gender:Female
Employee Language:Telugu
Employee Address:HYD
[Link]:
☛ Create an xml for the bookstore. Validate the same using both
DTD and XSD.
Solution :
[Link]
[Link]
<xs:complexTypename="bookstoreType">
<xs:sequence>
<xs:elementname="book"type="bookType"minOccurs="0"maxOccurs="u
nbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexTypename="bookType">
<xs:sequence>
<xs:elementname="title"type="xs:string"/>
<xs:elementname="author"type="xs:string"/>
<xs:elementname="price"type="xs:decimal"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
Output :
[Link]:
7. Design a controller with a Servlet that provides the interaction with
application developed in Experiment 1 and the database created in
Experiment 5.
[Link]
<html>
<head>
</head>
<body>
<form action="insert_data" method="post">
<caption>Employee Details</caption>
<tr>
<td>Username:</td>
</tr>
<tr>
<td>Password:</td>
</tr>
<tr>
<td>Email Id:</td>
</tr>
<tr>
<td>Mobile Number:</td>
</tr>
<tr>
<td>Gender:</td>
<td>
</tr>
<tr>
<td>Language:</td>
<td>
<select name="lang">
<option>English</option>
<option>Telugu</option>
<option>Marathi</option>
<option>Hindi</option>
</select>
</td>
</tr>
<tr>
<td>Address:</td>
<td>
</textarea>
</td>
</tr>
<tr>
</tr>
</table>
</form>
</body>
</html>
insert_data.java
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
[Link]("text/html");
String uname=[Link]("uname");
String pass=[Link]("pass");
String email=[Link]("email");
int mobno=[Link]([Link]("mobno"));
String gen=[Link]("gen");
String lang=[Link]("lang");
String addr=[Link]("addr");
try
[Link]("[Link]");
Connection
conn=[Link]("jdbc:oracle:thin:@localhost:1521:xe"
,"system","system");
Statement st=[Link]();
[Link]("Data is inserted.");
catch(Exception e)
[Link](e);
finally
[Link]();
}
**********OUTPUT**************
[Link]
<html>
<head>
</head>
<body>
<caption>Employee Details</caption>
<tr>
<td>Username:</td>
</tr>
<tr>
<td>Password:</td>
</tr>
<tr>
<td>Email Id:</td>
</tr>
<tr>
<td>Mobile Number:</td>
</tr>
<tr>
<td>Gender:</td>
<td>
</td>
</tr>
<tr>
<td>Language:</td>
<td>
<select name="lang">
<option>English</option>
<option>Telugu</option>
<option>Marathi</option>
<option>Hindi</option>
</select>
</td>
</tr>
<tr>
<td>Address:</td>
<td>
</textarea>
</td>
</tr>
<tr>
</table>
</form>
</body>
</html>
update_data.java
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
[Link]("text/html");
String uname=[Link]("uname");
String pass=[Link]("pass");
String email=[Link]("email");
int mobno=[Link]([Link]("mobno"));
String gen=[Link]("gen");
String lang=[Link]("lang");
String addr=[Link]("addr");
try
[Link]("[Link]");
Connection
conn=[Link]("jdbc:oracle:thin:@localhost:1521:xe"
,"system","system");
Statement st=[Link]();
[Link]("Data is updated.");
catch(Exception e)
[Link](e);
finally
[Link]();
*****************OUTPUT****************
Deleting data from a table:-
[Link]
<html>
<head>
</head>
<body>
<tr>
<td>Username:</td>
</tr>
<tr>
</tr>
</table>
</form>
</body>
</html>
delete_data.java
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
[Link]("text/html");
String uname=[Link]("uname");
try
[Link]("[Link]");
Connection
conn=[Link]("jdbc:oracle:thin:@localhost:1521:xe"
,"system","system");
Statement st=[Link]();
[Link]("Data is deleted.");
catch(Exception e)
[Link](e);
finally
[Link]();
}
***************OUTPUT****************
[Link]:
[Link] the transactional history of any user is very important.
Explore the various session tracking mechanism(Cookies, HTTP
Session) .
HTTP Session:-
[Link]
<html>
<head>
<body>
<table>
<tr>
<td>Username:</td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="upass"></td>
</tr>
<tr>
</tr>
</table>
</form>
</body>
</html>
[Link]
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
[Link]("text/html");
PrintWriter pw=[Link]();
String user=[Link]("uname");
HttpSession s=[Link]();
[Link]("user",user);
[Link]("<html><body>");
[Link]("Welcome:"+user);
[Link]("</html></body>");
[Link]("<a href='session1'>[Link]</a>");
[Link]
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
[Link]("text/html");
PrintWriter pw=[Link]();
HttpSession s=[Link](false);
String user=(String)[Link]("user");
[Link]("<html><body>");
[Link]("Welcome:"+user);
[Link]("</html></body>");
*********************************OUTPUT****************************
Cookies:-
[Link]
<html>
<head>
<body>
<table>
<tr>
<td>Username:</td>
</tr>
<tr>
<td>Password:</td>
</tr>
<tr>
</tr>
</table>
</form>
</body>
</html>
[Link]
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
[Link]("text/html");
PrintWriter pw=[Link]();
String user=[Link]("uname");
String pass=[Link]("upass");
HttpSession s=[Link]();
[Link](2000);
[Link](3000);
[Link](ck1);
[Link](ck2);
//Cookie ck[]=[Link]();
[Link]("<html><body>");
[Link]("Username is:"+user);
[Link]("Password is:"+pass);
[Link]("</html></body>");
[Link]("<a href='cookie1'>[Link]</a>");
[Link]
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
[Link]("text/html");
PrintWriter pw=[Link]();
Cookie ck[]=[Link]();
[Link]("<html><body>");
[Link]("Username is:"+ck[1].getValue());
[Link]("Password is:"+ck[2].getValue());
[Link]("</html></body>");
*******************************OUTPUT*****************************
[Link]:
☛ Create a custom server using http module and explore the other
modules of Node JS like OS, path, event.
Solution :
Execute the server script using the [Link] runtime. In the terminal, run:
node [Link]
This will start the HTTP server, and you should see the message "Server running at
[Link]
☛ Check OS Information:
In the same terminal where your server is running, you'll see information about your
operating system (OS) type, platform, architecture, CPU cores, etc.
The joined path using the path module is printed in the terminal.
☛ Check Custom Event:
The script emits a custom event and listens for it. In the terminal, you should see the
message "Custom Event Triggered: { message: 'Hello from custom event!' }".
To stop the server, press Ctrl+C in the terminal where the server is running.
[Link]
Output :
In the Terminal:
In the Browser:
Link: [Link]
[Link]:
Solution :
Firstly we need to create a new folder and open the folder in the command
prompt and enter a command as below:
npminit -y
[Link]
[Link](createTableQuery,(err)=>{
if(err){
[Link]([Link]);
}else{
[Link]('The students table has been created or already
exists.');
}
});
}
[Link]={initializeDatabase};
when we execute both the [Link] then the database will be created that
is [Link]
[Link]
[Link]('/',(req, res)=>{
[Link]('Welcome to the Student');
});
// Update a student
[Link]('/students/:id',(req, res)=>{
const id = [Link];
const{ name, age, grade }=[Link];
[Link]('UPDATE students SET name = ?, age = ?, grade = ? WHERE
id = ?',[name, age, grade, id],function(err){
if(err){
[Link]([Link]);
}
[Link]({updatedID:id});
});
});
// Delete a student
[Link]('/students/:id',(req, res)=>{
const id = [Link];
[Link]('DELETE FROM students WHERE id = ?', id,function(err){
if(err){
[Link]([Link]);
}
[Link]({deletedID:id});
});
});
[Link](port,()=>{
[Link]('Server running at [Link]
});
Output :
GET:
Open Postman.
Set the request type to GET.
Enter the URL: [Link]
POST : Create a New Student
Open Postman.
Set the request type to POST.
Enter the URL: [Link]
Go to the "Body" tab.
Select raw and set the body to JSON format.
GET: #all Students
Solution :
npxcreate-react-app weather-app
cd weather-app
In the project directory, install the necessary packages by executing the following
command
We will use the Axios library to make HTTP requests to the OpenWeatherMap API.
importReact,{useEffect,useState}from'react';
importaxiosfrom'axios';
constWeather=()=>{
const[city,setCity]=useState('');
const[weatherData,setWeatherData]=useState(null);
constfetchData=async()=>{
try{
constapiKey='c97c0c1086d42990e89d64d76f50bb61';// Replace with
your OpenWeatherMap API key
const response =[Link](
'[Link]
{city}&units=metric&appid=${apiKey}'
);
setWeatherData([Link]);
[Link]([Link]);//You can see all the weather data
in console log
}catch(error){
[Link](error);
}
};
useEffect(()=>{
fetchData();
},[]);
consthandleInputChange=(e)=>{
setCity([Link]);
};
consthandleSubmit=(e)=>{
[Link]();
fetchData();
};
return(
<div>
<form onSubmit={handleSubmit}>
<input
type="text"
placeholder="Enter city name"
value={city}
onChange={handleInputChange}
/>
<button type="submit">GetWeather</button>
</form>
{weatherData?(
<>
<h2>{[Link]}</h2>
<p>Temperature:{[Link]}C</p>
<p>Description:{[Link][0].description}</p>
<p>Feelslike :{[Link].feels_like}C</p>
<p>Humidity:{[Link]}%</p>
<p>Pressure:{[Link]}</p>
<p>WindSpeed:{[Link]}m/s</p>
</>
):(
<p>Loading weather data...</p>
)}
</div>
);
};
exportdefaultWeather;
Replace {YOUR_API_KEY} in the API URL with the API key you generated from
OpenWeatherMap.
importReactfrom'react';
importWeatherfrom'./Weather';
constApp=()=>{
return(
<div>
<h1>WeatherForecastApp</h1>
<Weather/>
</div>
);
};
exportdefaultApp;
Output :
Initial Screen
After Supply the City name
[Link]:
Solution :
Open your terminal and navigate to your preferred directory. Run the following
command to generate a new React app. Replace "todo-app" with your desired
project name:
This command will create a directory named "todo-app" with all the initial code
required for a React app.
cdtodo-app
npm start
This will open your React app, and you�ll see the default React starter page in your
web browser at '[Link]
In this step, we create the App component, which serves as the entry point to our
Todo List application.
importReactfrom'react';
importTodoListfrom'./components/TodoList';
functionApp(){
return(
<div className="App">
<TodoList/>
</div>
);
}
exportdefaultApp;
src->Component
Now, let's create the 'TodoList' component, which is responsible for managing the list
of tasks and handling task-related functionality.
importReact,{useState}from'react';
importTodoItemfrom'./TodoItem';
functionTodoList(){
const[tasks,setTasks]=useState([
{
id:1,
text:'Doctor Appointment',
completed:true
},
{
id:2,
text:'Meeting at School',
completed:false
}
]);
const[text,setText]=useState('');
functionaddTask(text){
constnewTask={
id:[Link](),
text,
completed:false
};
setTasks([tasks,newTask]);
setText('');
}
functiondeleteTask(id){
setTasks([Link](task=> [Link]!== id));
}
functiontoggleCompleted(id){
setTasks([Link](task=>{
if([Link]=== id){
return{task,completed:![Link]};
}else{
return task;
}
}));
}
return(
<div className="todo-list">
{[Link](task=>(
<TodoItem
key={[Link]}
task={task}
deleteTask={deleteTask}
toggleCompleted={toggleCompleted}
/>
))}
<input
value={text}
onChange={e=>setText([Link])}
/>
<button onClick={()=>addTask(text)}>Add</button>
</div>
);
}
exportdefaultTodoList;
src->Component
In this step, we create the 'TodoItem' component, which represents an individual task
in our Todo List.
importReactfrom'react';
functionTodoItem({ task,deleteTask,toggleCompleted}){
functionhandleChange(){
toggleCompleted([Link]);
}
return(
<div className="todo-item">
<input
type="checkbox"
checked={[Link]}
onChange={handleChange}
/>
<p>{[Link]}</p>
<button onClick={()=>deleteTask([Link])}>
X
</button>
</div>
);
}
exportdefaultTodoItem;
These three components, 'App', 'TodoList', and 'TodoItem', work together to create a
functional Todo List application in React. The 'TodoList' component manages the
state of the tasks, and the 'TodoItem' component represents and handles individual
tasks within the list.
Step 5: Styling
To enhance the visual appeal of your Todo List, you can apply some basic styling.
Here�s an example of how you can style the todo items. In the `[Link]` file, add
the following styles:
.todo-item{
display: flex;
justify-content: space-between;
margin-bottom:8px;
}
.todo-itemp{
color:#888;
text-decoration: line-through;
}