MC4212 Full Stack Web Development Lab
MC4212 Full Stack Web Development Lab
1
Date :
ADD CSS3 PROPERTIES OF STYLES TO INLIN, INTERNAL CSS3
PROPERTIES TO DOCUMENT
AIM: Add Styles to your Resume using CSS 3 Properties, Add External, Internal and Inline
CSS styles to know the priority & Add CSS3 Animation to your profile.
Inline CSS
An inline CSS is used to apply a unique style to a single HTML element.
An inline CSS uses the style attribute of an HTML element.
To use inline styles you use the style attribute in the relevant tag. The style
attribute can contain any CSS property.
Inline CSS has the highest priority out of the three ways you can use CSS:
external, internal, and inline.
Specify the desired CSS properties with the style HTML attribute.
<!DOCTYPE html>
<html>
<body>
</body>
</html>
OUTPUT
b) Internal CSS
An internal CSS is used to define a style for a single HTML page.
An internal CSS is defined in the <head> section of an HTML page, within a <style> element:
<!DOCTYPE html>
<html>
<head>
<style>
body {background-color: powderblue;}
h1 {color: blue;}
p {color: red;
align:center;}
</style>
</head>
<body>
<h1>This is a heading1</h1>
<p>This is a paragraph.</p>
</body>
</html>
Result : The above program was executed successfully, hence the output verified.
Ex.No: 2
Date :
FORM VALIDATION USING JAVASCRIPT
Program
<html>
<head>
<script>
function VALIDATEDETAIL()
{
var name = document.forms["RegForm"]["Name"];
var email = document.forms["RegForm"]["EMail"];
var phone = document.forms["RegForm"]["Telephone"];
var what = document.forms["RegForm"]["Subject"];
var password = document.forms["RegForm"]["Password"];
var address = document.forms["RegForm"]["Address"];
if (name.value == "")
{
window.alert("Please enter your name.");
name.focus();
return false;
}
if (address.value == "")
{
window.alert("Please enter your address.");
name.focus();
return false;
}
if (email.value == "")
{
window.alert("Please enter a valid e-mail address.");
email.focus();
return false;
}
if (email.value.indexOf("@", 0) < 0)
{
window.alert("Please enter a valid e-mail address.");
email.focus();
return false;
}
if (email.value.indexOf(".", 0) < 0)
{
window.alert("Please enter a valid e-mail address.");
email.focus();
return false;
}
if (phone.value == "")
{
window.alert("Please enter your telephone number.");
phone.focus();
return false;
}
if (password.value == "")
{
window.alert("Please enter your password");
password.focus();
return flase;
}
if (what.selectedIndex < 1)
{
alert("Please enter your course.");
what.focus();
return false;
}
return true;
}</script>
<style>
VALIDATEDETAIL {
font-weight: bold ;
float: left;
width: 100px;
text-align: left;
margin-right: 10px;
font-size:14px;
}
div {
box-sizing: border-box;
width: 100%;
border: 100px solid black;
float: left;
align-content: center;
align-items: center;
}
form {
margin: 0 auto;
width: 600px;
}</style></head>
<body>
<h1 style="text-align: center"> REGISTRATION FORM </h1>
<form name="RegForm" action="submit.php" onsubmit="return VALIDATEDETAIL()"
method="post">
OUTPUT
Result : The above program was executed successfully, hence the output verified.
Ex. No:3
Date :
Get data using Fetch API from an open-source endpoint and
display the contents in the form of a card.
AIM: To fetch data and display the contents in the form of a card.
script.js
// api url
const api_url =
"https://employeedetails.sriventech.ac.in/my/api/path";
// Storing response
const response = await fetch(url);
employee.html
<!DOCTYPE html>
<html lang="en">
<head>
<script src="script.js"></script>
Output
Result : The above program was executed successfully, hence the output verified.
Ex. No:4
Date :
JAVASCRIPT ARRAY FUNCTIONS
AIM: To use array function in Javascript.
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Arrays</h2>
<p id="demo"></p>
<p id="demo2"></p>
<p id="demo3"></p>
<script>
var cars = ["Saab", "Volvo", "BMW"];
document.getElementById("demo").innerHTML = cars;
</script>
<!-- Converting Arrays to Strings -->
<script>
var fruits = ["Banana", "Orange", "Apple", "Mango"];
document.getElementById("demo2").innerHTML = fruits.toString();
</script>
<!-- Joins all array elements -->
<script>
var fruits = ["Banana", "Orange", "Apple", "Mango"];
document.getElementById("demo3").innerHTML = fruits.join(" * ");
</script>
</body>
</html>
OUTPUT
Result : The above program was executed successfully, hence the output verified.
Ex. No:5
Date :
Create a NodeJS server using Express that stores data from a form as a JSON file
Aim : Create a NodeJS server using Express that stores data from a form as a JSON file and
displays it in another page. The redirect page should be prepared using Handlebars.
Steps :
1.Create a folder called fetch API in VS Code and create a new file JavaScript file
Now, write the Code get free API and store it in Const api_url get the used id from Api using
prompt method.
2. Convert into parseInt. Using asyn function get the API and point the needed data from the
API to Card. New show function get the Emp details in the table format and send it to html
file.
3.In HTML file create a Card using css file and Show the data fetched from the API. To
the table. Using “Id - demo" link the css file, Script file to the html and open it in Live
Server.
Server.js
const express = require ('express');
const expbs = require('express-handlebars'); const app = express();
app.use(express.urlencoded());
//routing
app.get('/', function(request, response, next){ response.render('index', { layout: false });
});
app.post('/', function(request, response, next){ response.send(request.body);
});
app.listen(2000);
=>(main.handlebar)
<html>
<head>
<title>
{{{ title }}}
</title>
</head>
<body>
{{{ body }}}
</body>
</html>
main.html
<html>
<head>
<title>
{{{ title }}}
</title>
</head>
<body>
{{{ body }}}
</body>
</html>
index.html
<h1>Student Form</h1>
<form action='/' method="post">
<Table style="font-size:20px;">
<tr>
<td><label for="name">Name:</label></td>
<td><input type="text" id="fname" name="name" placeholder="Your name.."></td>
</tr>
<tr>
<td><label for="reg">Register Number:</label></td>
<td><input type="text" id="lname" name="lastname" placeholder="Your number"></td>
</tr>
<tr>
<td><label for="city">City:</label></td>
<td><input id="subject" name="subject" placeholder="Your City" ></input></td>
</tr>
<tr>
<td><input type="submit" value="Submit"></td>
</tr>
</Table>
</form>
Output:
Result : The above program was executed successfully, hence the output verified.
Ex. No:6
Date :
Create a NodeJS server using Express that creates, insert, updates and deletes
customers details and stores them in MongoDB database. The information about the
user should be obtained from a HTML form.
create_database.js
var MongoClient = require('mongodb').MongoClient;
//Create a database named "mydb":
var url = "mongodb://localhost:27017/mydb";
Output
Creating a Collection
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";
Output
Insert data into Collection
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";
Output
Update document
Update the document with the address "Valley 345" to name="Mickey" and address="Canyon
123":
Output
Result : The above program was executed successfully, hence the output verified.
Ex. No:7
Date :
Create a NodeJS server that creates, reads, updates and deletes event details and stores
them in a MySQL database. The information about the user should be obtained from a
HTML form.
Procedure:
1. Create database in mysql
2. Write connection.php
3. Write php coding for reading data from database
<?php
include_once('connection.php');
$query="select * from emp where age>25";
$result=mysql_query($query);
?>
<!DOCTYPE html>
<html>
<head>
<title> Fetch Data From Database </title>
</head>
<body>
</t>
<?php
while($rows=mysql_fetch_assoc($result))
{
?>
<tr>
<td><?php echo $rows['empno']; ?></td>
<td><?php echo $rows['empname']; ?></td>
<td><?php echo $rows['age']; ?></td>
</tr>
<?php
}
?>
</table>
</body>
</html>
Output
+-------------+----------------+-----------------+-----------------+
Empno | Empname | Age |
+-------------+----------------+-----------------+-----------------+
| 1 | John Poul | 20 |
| 2 | Abdul S | 25 |
| 3 | Sanjay | 24 |
+-------------+----------------+-----------------+-----------------+
Result : The above program was executed successfully, hence the output verified.
Ex. No:8
Date :
Create a counter using ReactJS
<!DOCTYPE html>
<html lang="en">
<body style="text-align:center">
<h1>Fullstack</h1>
<p>COUNTS</p>
<div id="counter">
<!-- counts -->
</div>
<script>
let counts=setInterval(updated);
let upto=0;
function updated(){
var count= document.getElementById("counter");
count.innerHTML=++upto;
if(upto===1000)
{
clearInterval(counts);
}
}
</script>
</body>
</html>
OUTPUT
Result : The above program was executed successfully, hence the output verified.
Ex. No:9
Date :
Create and Deploy a virtual machine using a virtual box that can be
accessed from the host computer using SSH
Aim : To Create and Deploy a virtual machine using a virtual box that can be accessed from
the host computer using SSH
Procedure:
Prepare your computer for virtualization. Install Hypervisor (virtualization
tool).Import a virtual machine. Start the virtual machine. Using the virtual
machine. Shutdown the virtual machine
HOST – the computer on which you are running the hypervisor application.
Review File Sync Services for tools like OneDrive, Nextcloud, DropBox
Sync, iCloud, etc. If you are using a data synchronization service, make sure it DOES
NOT (or at least not frequently) synchronize the folder in which your hypervisor
imports and installs the Virtual Machines.
File sync services can cause a dramatic fall-off in performance for your
entire system as these services try to synchronize these massive files that are
getting updated constantly while you are using the Virtual Machines.
Once the Virtual Machine has been imported, it will normally show up
in the guest list within your hypervisor tool.
Example: sudo apt-get install vim – will install the vim text editor package on an
Ubuntu Linux Virtual Machine.
Find the IP address of your guest: Open a terminal and type ifconfig | more – The |
more (pronounced “pipe more”) will “pipe” the output of the ifconfig command to
the more command, which will show the results one page at a time, so it doesn’t
scroll by before you see it all.
RESULT:
The above program is executed successfully. Hence output verified.