Ip Lab Manual - Final - 2024
Ip Lab Manual - Final - 2024
Lab Objectives:
The Lab aims:
1. To orient students to HTML for making webpages
2. To expose students to CSS for formatting web pages
3. To expose students to developing responsive layout
4. To expose students to JavaScript to make web pages interactive
5. To orient students to React for developing front end applications
6. To orient students to Node.js for developing backend applications
TE (IT) SEM-V
Subject: IP Lab
Course Code: ITL501
List of Practical’s
BLOOM’S LAB
Sr. NAME OF THE PRACTICAL NO : OUTCOME
No. LEVEL
L1, L2,L3,L4
Write JS program to demonstrate Promise
6. ,L5,L6 LO4
and async / await
PRACTICAL NO : -01
Objective : Design / Create static website including Elements, Attributes, Hyperlink, Formatting, Images, Tables,
List, Frames, Forms, Multimedia.
<!DOCTYPE>
<HTML>
<HEAD><title> Student Registration Form </title>
<BODY>
<FORM>
<pre>
<h1> Student Registration Form </h1>
Website: <input type="url" name="website" required pattern="https?://.
+">
1 Select the color<input type="color" value="#b97a57"> 2 date <input
type="date" value="2011-06-08">
3 select the date &Time <input type="datetime" value="2011-06-09 T20:35:34.32">
4 Select the date time<input type="datetime-local" value="2011-06-09 T22:41">
5 E-mail Address<input type="email" value="[email protected]"> 6 <input
type="month" value="2011-06">
7 <input type="number" value="4">
8 <input type="range" value="15" min="2" max="10"> 9
<input type="search" value="[Any search text]">
10 <input type="tel" value="[Any numeric value]"> 11
<input type="time" value="22:38">
12 <input type="url" value="http://robertnyman.com"> 13 <input
type="week">
14 <input type="file">
<input type="submit" value="Login"> <input type="reset"
value="reset"> <input type="button" value="cancel">
</body>
<html>
4
Output :- To Design Student registration form using HTML.
5
PRACTICAL NO: -02
1] 1.html
6
2] frametarget.html
3] main.html
7
4] Sunset.jpg
8
PRACTICAL NO : -03
1] bootstrap.html
</div>
<div class="form-check d-flex justify-content-center mb-5">
<input
class="form-check-input me-2"
type="checkbox"
value=""
id="form2Example3cg"
/>
<label class="form-check-label"
for="form2Example3g">
I agree all statements in <a href="#!"
class="text-body"><u>Terms of service</u></a>
</label>
</div>
<div class="d-flex justify-content-center">
<button type="button" class="btn btn-success btnblock btn-lg gradient-custom- 4 text-
body">Register</button>
</div>
<p class="text-center text-muted mt-5 mb-0">Have
already an account? <a href="#!" class="fw-bold text-body"><u>Login
here</u></a></p>
</form>
</div>
</div>
10
</div></div></div></div>
</section>
2] new 1.css
.gradient-custom-3 {
/* fallback for old browsers */
background: #84fab0;
/* Chrome 10-25, Safari 5.1-6 */
background: -webkit-linear-gradient(to right, rgba(132, 250, 176,
0.5), rgba(143, 211, 244, 0.5));
/* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+
*/
background: linear-gradient(to right, rgba(132, 250, 176, 0.5),
rgba(143, 211, 244, 0.5))
}
.gradient-custom-4 {
/* fallback for old browsers */
background: #84fab0;
/* Chrome 10-25, Safari 5.1-6 */
background: -webkit-linear-gradient(to right, rgba(132, 250, 176,
11
Output :-
12
PRACTICAL NO : -04
1] student.html
Input :-
<html>
<head>
<title>Student Registation form</title>
<Script language="JavaScript">
function Validate()
{
if(document.f1.fname.value==" ")
{
alert("Please Enter the first Name");
return false;}
if(document.f1.lname.value==" ")
{
alert("Please Enter the last Name");
return false;
}
if(document.f1.gender[0].checked==" " &&
document.f1.gender[1].checked==" ")
{
alert("Please Select the gender");
return false;
}
if(document.f1.DD.value==" " || document.f1.MM.value== " " ||
document.f1.YYYY.value==" ")
{
alert("Please Select the date");
13
return false;
}
if(document.f1.addr.value==" ")
{
alert("Please Enter the address");
return false;
}
if(document.f1.eid.value.indexOf('@')==-1)
{
3.     Gender
            
:-
  
<input type="radio" name="gender" > Male<br>
nbsp        
nbsp
<input type="radio" name="gender" > Female<br><br>
5.     Address
            
:-
  
<input type="Text" name="addr" size=30 value=" "><br><br>
6.     Email
nbsp :-   
<input type="Text" name="eid" size=30 value=" "><br><br>
8. Hobbies
<input type="Checkbox" name="Hobby" value=" "> Reading<br>
15
<input type="Checkbox" name="Hobby" value=" "> Dancing<br>
<input type="Checkbox" name="Hobby" value=" "> Singing<br>
<input type="Checkbox" name="Hobby" value=" "> Sports<br>
<input type="Submit" name="submit" value=" Submit " onClick="return
Validate()">
<input type="Reset" name="reset" value=" Reset ">
<input type="Button" name="cancel" value=" Cancel ">
</font>
</form>
</body>
</html>
16
Output :-
2] submitform.html
Input :-
17
PRACTICAL NO : -05
map() method: It applies a given function on all the elements of the array and returns the updated array.
output
// [2, 4, 6, 8]
Filter
The filter() method takes each element in an array and it applies a conditional statement against it. If
this conditional returns true, the element gets pushed to the output array. If the condition returns false,
the element does not get pushed to the output array.
const numbers = [1, 2, 3, 4];
const evens = numbers.filter(item => item % 2 === 0);
console.log(evens);
output
// [2, 4]
Reduce
The reduce() method reduces an array of values down to just one value. To get the output value, it runs
a reducer function on each element of the array.
Outcome: Thus we have develop ES6 features in functions using map, reduce, filter.
18
PRACTICAL NO : -06
async keyword with a function to represent that the function is an asynchronous function. The async
function returns a promise.
// async function
async function asyncFunc() {
console.log(result);
console.log('hello');
}
Promise resolved
hello
19
Practical No: 7
Objective: Implement React js in “Hello World”
App.js
function App() {
return (
<h1> Hello World! </h1>
);
}
Step to run the application: Enter the following command to run the application.
npm start
20
PRACTICAL NO: -08
return (
<div style={{ margin: '50px' }}>
<h1>Welcome to Geeks for Geeks </h1>
<h3>Counter App using Functional Component : </h3>
<h2>{count}</h2>
<button onClick={increase}>Add</button>
</div>
)
}
21
Practical No: 9
Ex.
class ParentComponent extends Component {
render() {
return (
<ChildComponent name="First Child" />
);
}
}
Firstly, we need to define/get some data from the parent component and assign it to a child
component’s “prop” attribute.
return <p>{props.name}</p>;
State:
React has another special built-in object called state, which allows components to create and manage
their own data. So unlike props, components cannot pass data with state, but they can create and
manage it internally.
render() {
return (
<div>
<p>{this.state.id}</p>
<p>{this.state.name}</p>
</div>
);
}
}
How do you update a component’s state?
State should not be modified directly, but it can be modified with a special method called setState( ).
this.setState({ // correct
id: "2020"
});
npm init –y
{
"name": "EMS", // The name of your project
"version": "0.92.12", // The version of your project
"description": " The expense Mgmt System. , // The description of your project
"main": "index.js" // entry point
"license": "MIT" // The license of your project
}
app.js
23
Step 5
Now, the Server is running. Here, we will create the server running on 5000 ports for this example. Just
type localhost:5000 in your browser address bar and press Enter. See the below screenshot for how to
run this example.
output
24
PRACTICAL NO: -10
Main.js
const express = require('express');
const mongoose = require('mongoose');
const session = require('express-session');
require('dotenv').config();
const app = express();
const PORT = process.env.PORT || 5500;
// Middleware
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(
session({
secret: 'complex-secret-key',
resave: false,
saveUninitialized: true,
})
);
mongoose
.connect(process.env.DB_URI)
.then(() => console.log('Database is Connected sucessfully'))
.catch((error) => console.error(error));
// Routes
const routes = require('./routes/routes');
app.use('/', routes);
26
Outcome: Thus we have implemented Fetch data from a MongoDB database using Node.js
27
PRACTICAL NO : -12
Objective : Nodejs, express js in CRUD REST API ( GET , POST , PUT, DELETE) operation.
server.js
const express = require('express');
const colors = require('colors');
const cors = require('cors');
const app = express();
const userModel = require('./models/userModel');
const connectDB = require('./db');
const PORT = 5000;
app.use(cors());
app.use(express.json());
connectDB();
// API
//post request
app.post('/api/student_post', async (req, res) => {
const { name, email, password } = req.body;
const userData = await userModel.create({ name, email, password });
res.status(201).json(userData);
});
//Update Request
app.put('/api/student_update/:id', async (req, res) => {
const id = req.params.id;
const body = req.body;
const updateData = await userModel.findByIdAndUpdate({ _id: id }, body);
res.json(updateData);
});
// Delete Request
28
app.listen(PORT, () => {
console.log(`Server is Running on PORT ${PORT}`.bgYellow.bold);
});
module.exports = User;
db.js
module.exports = connectDB;
29
Outcome: Thus we have implemented to perform CRUD operations.
30