Protofolio
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>My Portfolio</title>
<style>
body { font-family: Arial; margin: 0; padding: 20px; background: #f0f0f0; }
header { background: #333; color: white; padding: 20px; text-align: center; }
section { margin: 20px 0; }
</style>
</head>
<body>
<header>
<h1>Nithin Irukulla</h1>
<p>Web Developer | Programmer</p>
</header>
<section>
<h2>About Me</h2>
<p>Passionate developer experienced in HTML, CSS, JS, and MERN stack.</p>
</section>
<section>
<h2>Projects</h2>
<ul>
<li>Fitness Activity Recognition</li>
<li>Amazon Clone</li>
</ul>
</section>
</body>
</html>
Product Page
<!DOCTYPE html>
<html>
<head>
<title>Product Page</title>
<style>
.product { padding: 20px; background: # f; width: 300px; border: 1px solid #ccc; margin:
auto; }
img { width: 100%; }
</style>
</head>
<body>
<div class="product">
<img src="https://via.placeholder.com/300" alt="Product" />
<h2>Wireless Headphones</h2>
<p>Price: ₹2999</p>
<button>Add to Cart</button>
</div>
</body>
</html>
3. Random Number Generation
<!DOCTYPE html>
ff
<html>
<body>
<h2>Generate Random Number</h2>
<button onclick="generate()">Click Me</button>
<p id="result"></p>
<script>
function generate() {
const random = Math. oor(Math.random() * 100) + 1;
document.getElementById('result').innerText = `Random Number: ${random}`;
}
</script>
</body>
</html>
4. Palindrome Check
<!DOCTYPE html>
<html>
<body>
<h2>Palindrome Checker</h2>
<input type="text" id="word" placeholder="Enter a word" />
<button onclick="checkPalindrome()">Check</button>
<p id="output"></p>
<script>
function checkPalindrome() {
const str = document.getElementById('word').value;
const reversed = str.split('').reverse().join('');
document.getElementById('output').innerText =
str === reversed ? "It's a Palindrome!" : "Not a Palindrome.";
}
</script>
</body>
</html>
5) Form to Accept Data and Respond Using Express.js
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.get('/', (req, res) => {
res.send(`
<form action="/submit" method="POST">
Name: <input type="text" name="name"/><br/>
Email: <input type="email" name="email"/><br/>
<button type="submit">Submit</button>
</form>
`);
});
app.post('/submit', (req, res) => {
const { name, email } = req.body;
res.send(`Hello ${name}, your email is ${email}`);
});
fl
app.listen(3000, () => {
console.log("Server running on port 3000");
});
6) Program to Demonstrate Rendering Views in Express.js
<!DOCTYPE html>
<html>
<head>
<title>Render Demo</title>
</head>
<body>
<h1>Hello <%= name %>!</h1>
</body>
</html>
const express = require('express');
const app = express();
app.set('view engine', 'ejs');
app.get('/', (req, res) => {
res.render('index', { name: "Nithin" });
});
app.listen(3000, () => {
console.log("Server is running on port 3000");
});
project/
views/
index.ejs
app.js
7) Retrieve All Users Using MongoDB
npm install express mongoose
const express = require('express');
const mongoose = require('mongoose');
const app = express();
mongoose.connect('mongodb://localhost:27017/userdb', {
useNewUrlParser: true,
useUni edTopology: true
});
const userSchema = new mongoose.Schema({
name: String,
email: String
});
const User = mongoose.model('User', userSchema);
app.get('/users', async (req, res) => {
const users = await User. nd();
res.json(users);
});
fi
fi
app.listen(3000, () => {
console.log("Server running on port 3000");
});