Sdc
OGRAM 2: Make the above web application responsive web
application using Bootstrap framework.
bootstrap.html
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bootstrap usage</title>
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.mi
n.css" rel="stylesheet" integrity="sha384-
sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJ
LB" crossorigin="anonymous">
</head>
<body>
<main>
<h1 class="container mt-5">Login Here</h1>
<form class="mb-3" action="#">
<label class="form-label">EMAIL</label><input type="text" class="form-
control" id="email" name="email">
<label class="form-label" >PASSWORD</label><input type="password"
class="form-control" id="password" name="password">
<input type="submit" class="btn btn-primary" id="" value="login">
</main>
</body>
</html>
PROGRAM 9 : Create a custom server using http module and explore the other modules of
NodeJS like OS, path, event.
server.js
// Import modules
const http = require('http');
const os = require('os');
const path = require('path');
const EventEmitter = require('events');
// Create event emitter
const eventEmitter = new EventEmitter();
// Custom event
eventEmitter.on('requestReceived', () => {
console.log("A client request was received!");
});
// Create server
const server = http.createServer((req, res) => {
// Emit event
eventEmitter.emit('requestReceived');
// OS Module Example
const systemInfo = {
platform: os.platform(),
cpuArchitecture: os.arch(),
totalMemory: os.totalmem(),
freeMemory: os.freemem(),
hostname: os.hostname()
};
// Path Module Example
const filePath = path.join(__dirname, 'sample.txt');
res.writeHead(200, { 'Content-Type': 'application/json' });
system: systemInfo,
filePath: filePath
}, null, 2));
res.end();
});
// Server Port
const PORT = 3000;
// Start server
server.listen(PORT, () => {
console.log(`Server running at
http://localhost:${PORT}`);
});
Comments
Post a Comment