Header 1 Header 2 Row 1, Cell 1 Row 1, Cell 2 Row 2, Cell 1 Row 2, : Notes">

NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

lab 1 -a
table html

<!DOCTYPE html>
<html>
<head>
<title>Simple Table</title>
</head>
<body>
<table border="1">
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
</tr>
<tr>
<td>Row 2, Cell 1</td>
<td>Row 2, Cell 2</td>
</tr>
</table>
</body>
</html>

***********************************************************************************************************************************************

lab 1-b

form html

<!DOCTYPE html>
<html>
<head>
<title>Simple Form</title>
</head>
<body>
<h2>Registration Form</h2>
<form action="process.php" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required><br><br>

<label for="email">Email:</label>
<input type="email" id="email" name="email" required><br><br>

<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br><br>

<label for="about">About:</label><br>
<textarea id="about" name="about" rows="4" cols="50"></textarea><br><br>

<input type="submit" value="Submit">
</form>
</body>
</html>


************************************************************************************************************************************************

lab 2

inline internal and external css

<!DOCTYPE html>
<html>
<head>
<title>CSS Examples</title>
<style>
/* Internal CSS */
h1 {
color: blue;
}

/* Embedded CSS */
.paragraph {
font-size: 16px;
text-align: center;
}
</style>
</head>
<body>
<h1 style="color: red;">Inline CSS Example</h1>
<p class="paragraph">This is a paragraph with internal and embedded CSS styles.</p>
</body>
</html>


*********************************************************************************************************************************************

lab 3

form using bootstrap

<!DOCTYPE html>
<html>
<head>
<title>Simple Bootstrap Form</title>
<!-- Include Bootstrap CSS from a CDN -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<h2>Registration Form</h2>
<form>
<div class="form-group">
<label for="username">Username:</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>

<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>

<div class="form-group">
<label for="password">Password:</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>

<div class="form-group">
<label for="about">About:</label>
<textarea class="form-control" id="about" name="about" rows="4"></textarea>
</div>

<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>

</body>
</html>

************************************************************************************************************************************************

lab - 4

credential validation js

<!DOCTYPE html>
<html>
<head>
<title>Registration Form</title>
</head>
<body>
<h2>Registration Form</h2>
<form onsubmit="return validateForm()">
<div>
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<p id="usernameError" style="color: red;"></p>
</div>

<div>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<p id="emailError" style="color: red;"></p>
</div>

<div>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
</div>

<div>
<label for="confirmPassword">Confirm Password:</label>
<input type="password" id="confirmPassword" required>
<p id="passwordError" style="color: red;"></p>
</div>

<button type="submit">Register</button>
</form>

<script>
function validateForm() {
var username = document.getElementById('username').value;
var email = document.getElementById('email').value;
var password = document.getElementById('password').value;
var confirmPassword = document.getElementById('confirmPassword').value;

var usernameError = document.getElementById('usernameError');
var emailError = document.getElementById('emailError');
var passwordError = document.getElementById('passwordError');

// Simple username validation (minimum 3 characters)
if (username.length < 3) {
usernameError.textContent = 'Username must be at least 3 characters.';
return false;
} else {
usernameError.textContent = '';
}

// Simple email validation
if (!isValidEmail(email)) {
emailError.textContent = 'Invalid email address.';
return false;
} else {
emailError.textContent = '';
}

// Password and confirm password validation
if (password !== confirmPassword) {
passwordError.textContent = 'Passwords do not match.';
return false;
} else {
passwordError.textContent = '';
}

return true;
}

function isValidEmail(email) {
// A simple email validation regex
var emailRegex = /S+@S+.S+/;
return emailRegex.test(email);
}
</script>
</body>
</html>

***********************************************************************************************************************************************

lab 5

keyboard and mouse events

<!DOCTYPE html>
<html>
<head>
<title>Keyboard and Mouse Actions</title>
</head>
<body>
<h2>Keyboard and Mouse Actions</h2>

<!-- Keyboard Actions -->
<p>Press any key: <span id="keyPressResult">Press a key...</span></p>
<p>Release a key: <span id="keyReleaseResult">Release a key...</span></p>

<!-- Mouse Actions -->
<button id="clickButton">Click me</button>
<p id="mouseHoverArea">Hover over this text.</p>

<script>
// Keyboard Actions
document.addEventListener('keydown', function (event) {
document.getElementById('keyPressResult').textContent = `Key pressed: ${event.key}`;
});

document.addEventListener('keyup', function (event) {
document.getElementById('keyReleaseResult').textContent = `Key released: ${event.key}`;
});

// Mouse Actions
document.getElementById('clickButton').addEventListener('click', function () {
alert('Button Clicked!');
});

document.getElementById('mouseHoverArea').addEventListener('mouseenter', function () {
document.getElementById('mouseHoverArea').textContent = 'Mouse is over this text.';
});

document.getElementById('mouseHoverArea').addEventListener('mouseleave', function () {
document.getElementById('mouseHoverArea').textContent = 'Hover over this text.';
});
</script>
</body>
</html>

************************************************************************************************************************************************

lab - 6

<!DOCTYPE html>
<html>
<head>
<title>XMLHttpRequest Example</title>
</head>
<body>
<h2>Retrieve Data from Online Source</h2>
<button id="loadDataButton">Load Data</button>
<div id="output"></div>

<script>
// Function to make an XMLHttpRequest and retrieve data from an online source
function loadData() {
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://example.com/your-data-url', true);

xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
var responseText = xhr.responseText;
document.getElementById('output').textContent = responseText;
}
};

xhr.send();
}

// Attach the loadData function to the button click event
document.getElementById('loadDataButton').addEventListener('click', loadData);
</script>
</body>
</html>

************************************************************************************************************************************************

lab 9

online validation using jquery

<!DOCTYPE html>
<html>
<head>
<title>jQuery Form Validation</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<h2>Registration Form</h2>
<form id="registrationForm">
<div>
<label for="username">Username:</label>
<input type="text" id="username" name="username">
<p class="error" id="usernameError"></p>
</div>

<div>
<label for="email">Email:</label>
<input type="email" id="email" name="email">
<p class="error" id="emailError"></p>
</div>

<div>
<label for="password">Password:</label>
<input type="password" id="password" name="password">
</div>

<div>
<label for="confirmPassword">Confirm Password:</label>
<input type="password" id="confirmPassword">
<p class="error" id="passwordError"></p>
</div>

<button type="submit">Register</button>
</form>

<button id="submittedAlert" style="display: none">Submitted</button>

<script>
$(document).ready(function () {
$('#registrationForm').submit(function (event) {
event.preventDefault();
if (validateForm()) {
$('#submittedAlert').show();
}
});

function validateForm() {
const username = $('#username').val();
const email = $('#email').val();
const password = $('#password').val();
const confirmPassword = $('#confirmPassword').val();

const errors = $('.error').text('');

if (username.length < 3) {
errors.filter('#usernameError').text('Username must be at least 3 characters.');
}

if (!isValidEmail(email)) {
errors.filter('#emailError').text('Invalid email address.');
}

if (password !== confirmPassword) {
errors.filter('#passwordError').text('Passwords do not match.');
}

return errors.filter('.error:empty').length === 0;
}

function isValidEmail(email) {
const emailRegex = /S+@S+.S+/;
return emailRegex.test(email);
}
});
</script>
</body>
</html>

************************************************************************************************************************************************

lab 10 , 11

simple app using django

cmd:
django-admin startproject mysite

cmd:
python manage.py runserver


change to same dir as manage.py
python manage.py startapp polls


polls/views.py
from django.http import HttpResponse

def index(request):
return HttpResponse("Hello, world. You're at the polls index.")


polls/urls.py
from django.urls import path

from . import views

urlpatterns = [
path("", views.index, name="index"),
]


mysite/urls.py
from django.contrib import admin
from django.urls import include, path

urlpatterns = [
path("polls/", include("polls.urls")),
path("admin/", admin.site.urls),
]

cmd:
python manage.py migrate

polls/models.py
from django.db import models


class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField("date published")
def __str__(self):
return self.question_text


class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
def __str__(self):
return self.choice_text


mysite/settings.py
INSTALLED_APPS = [
"polls.apps.PollsConfig", //this wont be available initially, type this inside INSTALLED_APPS
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
]

cmd:
python manage.py makemigrations polls

cmd:
python manage.py sqlmigrate polls 0001

cmd:
python manage.py migrate

*imp: ensure u are in right directory
create admin user(cmd):
python manage.py createsuperuser
//set username, pass, email

cmd: #start server
python manage.py runserver

# check indentations accordingly b4 copying

***********************************************************************************************************************************************

lab 11

scrapy web scraping

cmd
pip instal scrapy

cmd
scrapy startproject scrapeme_scraper

cmd
cd scrapeme_scraper
scrapy genspider scrapeme scrapeme.live/shop/


scrapeme_spider/spiders/scrapme.py

import scrapy

class ScrapemeSpider(scrapy.Spider):
name = "scrapeme"
allowed_domains = ["scrapeme.live"]
start_urls = ["https://scrapeme.live/shop/"]

def parse(self, response):
# get all HTML product elements
products = response.css(".product")
# iterate over the list of products
for product in products:
# get the two price text nodes (currency + cost) and
# contatenate them
price_text_elements = product.css(".price *::text").getall()
price = "".join(price_text_elements)

# return a generator for the scraped item
yield {
"name": product.css("h2::text").get(),
"image": product.css("img").attrib["src"],
"price": price,
"url": product.css("a").attrib["href"],
}


cmd
scrapy crawl scrapeme -O products.csv
//same dir as scrapme.py spider

//check indentations accordingly b4 copying

************************************************************************************************************************************************
India Map state click embed

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Indian States Map</title>
</head>
<body>

<h1>Clickable Indian States Map</h1>

<img src="india-map.jpg" usemap="#image-map">

<map name="image-map">
<area target="" alt="UP" title="UP" href="https://en.wikipedia.org/wiki/Uttar_Pradesh" coords="621,721,951,922,972,745,595,553" shape="poly">
<area target="" alt="Maha" title="Maha" href="https://en.wikipedia.org/wiki/Maharashtra" coords="296,1198,780,1105,745,1148,339,1481,288,1209" shape="poly">
<area target="" alt="MP" title="MP" href="https://en.wikipedia.org/wiki/Madhya_Pradesh" coords="446,962,430,1099,830,1055,886,891,474,969" shape="poly">
<area target="" alt="ktaka" title="ktaka" href="https://en.wikipedia.org/wiki/Karnataka" coords="582,1353,402,1439,421,1666,591,1726,625,1613,533,1608" shape="poly">
<area target="" alt="tn" title="tn" href="https://en.wikipedia.org/wiki/Tamil_Nadu" coords="542,1771,747,1642,728,1800,652,1901,582,1958,595,1878,604,1852,587,1787,566,1779,739,1799,724,1802" shape="poly">
<area target="" alt="Raj" title="Raj" href="https://en.wikipedia.org/wiki/Rajasthan" coords="131,742,412,589,588,747,486,814,419,914,213,876" shape="poly">
<area target="" alt="jk" title="jk" href="https://en.wikipedia.org/wiki/Jammu_and_Kashmir_(union_territory)" coords="413,169,728,188,656,343,429,319" shape="poly">
<area target="" alt="Assam" title="Assam" href="https://en.wikipedia.org/wiki/Assam" coords="1340,754,1630,645,1532,758,1518,758,1329,788,1316,750" shape="poly">
</map>

<!-- https://www.google.com/url?sa=i&url=https%3A%2F%2Fcommons.wikimedia.org%2Fwiki%2FFile%3AIndia-map-en.svg&psig=AOvVaw0_H2bM0IqNw0rhmJGbypRi&ust=1700460496992000&source=images&cd=vfe&opi=89978449&ved=0CBIQjRxqFwoTCJiuzJCzz4IDFQAAAAAdAAAAABAE -->
<!-- this code works properly only foor the above img so download it from the above link (save img as india-map.jpg) -->
<!-- clickable states UP, maha, MP, Rajasthan, TN, Karnataka, Assam, JK -->


</body>
</html>

************************************************************************************************************************************************
body part embed

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Human Body Image</title>
</head>
<body>

<h1>Click on the Human Body</h1>

<img src="hb1.jpg" usemap="#image-map">

<map name="image-map">
<area target="" alt="hair" title="hair" href="" coords="1252,500,1318,293,1406,211,1491,203,1610,230,1647,248,1700,312,1721,405,1760,516,1411,347,1345,487" shape="poly" onclick="showAlert('Hair')">
<area target="" alt="eyes" title="eyes" href="" coords="1379,485,1604,548" shape="rect" onclick="showAlert('Eyes')">
<area target="" alt="nose" title="nose" href="" coords="1450,559,1522,548,1519,585,1453,588,1437,559" shape="poly" onclick="showAlert('Nose')">
<area target="" alt="left ear" title="left ear" href="" coords="1249,503,1323,609" shape="rect" onclick="showAlert('Left Ear')">
<area target="" alt="right ear" title="right ear" href="" coords="1681,514,1742,604" shape="rect" onclick="showAlert('Right Ear')">
<area target="" alt="mouth" title="mouth" href="" coords="1432,601,1556,659" shape="rect" onclick="showAlert('Mouth')">
<area target="" alt="neck" title="neck" href="" coords="1453,715,1538,842" shape="rect" onclick="showAlert('Neck')">
<area target="" alt="left hand" title="left hand" href="" coords="1223,927,1247,1125,963,1530,871,1491" shape="poly" onclick="showAlert('Left Hand')">
<area target="" alt="right hand" title="right hand" href="" coords="1774,945,1747,1123,2033,1528,2091,1446,2150,1512" shape="poly" onclick="showAlert('Right Hand')">
<area target="" alt="fingers on left hand" title="fingers on left hand" href="" coords="827,1536,777,1600,832,1558,798,1600,787,1637,816,1621,859,1576,824,1650,896,1534,906,1587,864,1626,832,1637,861,1515,938,1536,957,1558,973,1568,978,1624" shape="poly" onclick="showAlert('Fingers On Left Hand')">
<area target="" alt="fingers on right hand" title="fingers on right hand" href="" coords="2019,1594,2032,1628,2082,1567,2218,1541,2168,1653,2213,1600,2160,1637,2046,1552,2128,1595,2139,1494" shape="poly" onclick="showAlert('Fingers On Right Hand')">
<area target="" alt="left shoulder" title="left shoulder" href="" coords="1236,959,1408,823" shape="rect" onclick="showAlert('Left Shoulder')">
<area target="" alt="right shoulder" title="right shoulder" href="" coords="1599,810,1758,959" shape="rect" onclick="showAlert('Right Shoulder')">
<area target="" alt="chest" title="chest" href="" coords="1300,977,1707,1054" shape="rect" onclick="showAlert('Chest')">
<area target="" alt="stomach" title="stomach" href="" coords="1337,1162,1673,1311" shape="rect" onclick="showAlert('Stomach')">
<area target="" alt="left leg" title="left leg" href="" coords="1270,1536,1474,1549,1310,2590,1175,2600" shape="poly" onclick="showAlert('Left Leg')">
<area target="" alt="toes on left leg" title="toes on left leg" href="" coords="1109,2664,1257,2682,1217,2786,1051,2738" shape="poly" onclick="showAlert('Toes on Left LEg')">
<area target="" alt="toes on right leg" title="toes on right leg" href="" coords="1734,2685,1895,2661,1940,2730,1800,2793" shape="poly" onclick="showAlert('Toes On Right Leg')">
<area target="" alt="right leg" title="right leg" href="" coords="1511,1554,1723,1544,1824,2529,1673,2529" shape="poly" onclick="showAlert('Right Leg')">
</map>

<!-- https://static.vecteezy.com/system/resources/previews/001/879/299/original/boy-body-anatomy-drawing-cute-cartoon-illustration-vector.jpg -->
<!-- code only works for the above img use link to download -->
<!-- save as hb1.jpg -->
<!-- clickable body parts eyes, ears(left/ right separate), hair, nose, mouth, neck, right hand, right fingers, left hand left fingers, left shoulder, right shoulder, chest, stomach, left leg, left toes, right leg, right toes -->

<script>
function showAlert(bodyPart) {
alert("You touched the " + bodyPart + ".");
}
</script>

</body>
</html>

************************************************************************************************************************************************
dynamic weather app

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Weather App (OpenWeatherMap)</title>
</head>
<body>

<h1>Weather App (OpenWeatherMap)</h1>

<form id="weatherForm">
<label for="cityInput">Enter City:</label>
<input type="text" id="cityInput" placeholder="Enter city name" required>
<button type="button" onclick="getWeather()">Get Weather</button>
</form>

<div id="weatherInfo"></div>

<script>
function getWeather() {
const cityInput = document.getElementById("cityInput").value;

// Replace 'YOUR_API_KEY' with your actual OpenWeatherMap API key
const apiKey = 'key';
const apiUrl = `https://api.openweathermap.org/data/2.5/weather?q=${cityInput}&appid=${apiKey}`;

fetch(apiUrl)
.then(response => response.json())
.then(data => {
const weatherInfoDiv = document.getElementById("weatherInfo");

if (data.cod === "404") {
weatherInfoDiv.innerHTML = `<p>City not found. Please enter a valid city name.</p>`;
} else {
const temperature = data.main.temp;
const description = data.weather[0].description;
const cityName = data.name;

weatherInfoDiv.innerHTML = `<p>${cityName}: ${temperature}°C, ${description}</p>`;
}
})
.catch(error => {
console.error('Error fetching weather data:', error);
});
}
</script>

</body>
</html>

NOTE: use any 1 key not all 3 all 3 are working
c48c64ed42c912b5d03c640decd3c23c
91a3d8a26d5f15a2bba7f681552c977b
e03e485b7ad725aa57d3c86eb104f8e7
***********************************************************************************************************************************************
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.