Posts

Showing posts from February, 2026

Slip 5-SPA

 Using angular 13 create a SPA to carry out validation for a username entered in a textbox. If the textbox is blank, alert “Enter username”. If the number of characters is less than three, alert ‟ Username is too short”. If value entered is appropriate the print “Valid username” and password should be minimum 8 characters. app.component.ts import { Component } from '@angular/core' ; @ Component ({   selector: 'app-root' ,   templateUrl: './app.component.html' }) export class AppComponent {   username : string = '' ;   password : string = '' ;   message : string = '' ;   validateForm () {     if ( this . username . trim () === '' ) {       alert ( "Enter username" );       return ;     }     if ( this . username . length < 3 ) {       alert ( "Username is too short" );       return ;     }     if ( this . password . len...

Using angular js Create a SPA that show Syllabus content of all subjects of M.Sc (CS) Sem-II (use ng-view)

 1.ng new msc-syllabus cd msc-syllabus ng serve 2.ng generate component os ng generate component java ng generate component ds ng generate component cn app-routing.module.ts import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; import { OsComponent } from './os/os.component'; import { JavaComponent } from './java/java.component'; import { DsComponent } from './ds/ds.component'; import { CnComponent } from './cn/cn.component'; const routes: Routes = [   { path: 'os', component: OsComponent },   { path: 'java', component: JavaComponent },   { path: 'ds', component: DsComponent },   { path: 'cn', component: CnComponent } ]; @NgModule({   imports: [RouterModule.forRoot(routes)],   exports: [RouterModule] }) export class AppRoutingModule { } app.component.html <h2>M.Sc (CS) Sem-II Syllabus</h2> <nav>   <a routerLink="/os">Operating Sys...

Using angular js display the 10 student details in Table format (using ng-repeat directive use Array to store data)

app.component.ts import { Component } from '@angular/core' ; @ Component ({   selector : 'app-root' ,   templateUrl : './app.component.html' ,   styleUrls : [ './app.component.css' ] }) export class AppComponent {   title = 'student' ;   students = [     { id : 1 , name : 'sonu' , course : 'FYBSc' , marks : 60 },     { id : 2 , name : 'Ram' , course : 'FYBSc' , marks : 60 },     { id : 1 , name : 'sonu' , course : 'FYBSc' , marks : 60 }   ]; }   app.component.html < h2 > Student data </ h2 > < table border = "1" >   < tr >     < th > ID </ th >     < th > Name </ th >     < th > Course </ th >     < th > Marks </ th >   </ tr >   < tr *ngFor = "let s of students" >     < td > {{ s.id }} </ td >     < td > {{ s.name }} </ td > ...

Write angular13 by using ng-click directive to display an alert message after clicking the element.

app.component.html < button (click) = "showAlert()" > Click Me </ button >  app.componet.ts import { Component } from '@angular/core' ; @ Component ({   selector: 'app-root' ,   templateUrl: './app.component.html' ,   styleUrls: [ './app.component.css' ] }) export class AppComponent {   title = 'slip6' ;   showAlert ()   {     alert ( "Button Clicked" )   } }

Slip 11: Write node js application that transfer a file as an attachment on web and enables browser to prompt the user to download file using express js.

  const express = require ( 'express' ); const path = require ( 'path' ); const app = express (); const PORT = 3000 ; // Route to download file app . get ( '/download' , ( req , res ) => {     res . download ( 'a.txt' , ( err ) => {         if ( err ) {             console . log ( "Error downloading file:" , err );         } else {             console . log ( "File sent successfully" );         }     }); }); // Home app . get ( '/' , ( req , res ) => {     res . send ( '<h2>Click below to download file</h2><a href="/download">Download File</a>' ); }); app . listen ( PORT , () => {     console . log ( `Server running at http://localhost: ${ PORT } ` ); });

Slip 7 Create a node js file named main.js for event-driven application. There should be a main loop that listens for events, and then triggers a callback function when one of those events is detected.

 // import event module var events = require('events'); // create an eventEmitter object var eventEmitter = new events.EventEmitter(); // create an event handler var connectHandler = function (s) {    console.log('Its', s); }; // Bind the data_received event eventEmitter.on('data_received', function (name) {    console.log(name, "Understood event -Driven"); }); // trigger data_received event eventEmitter.emit('data_received', "FYMSC(CS)"); // Bind the connection event eventEmitter.on('connection', connectHandler); // trigger connection event eventEmitter.emit('connection', "SIMPLE SOLUTION"); console.log("program Ended");

Slip5:Create a Node.js file that writes an HTML form, with an upload field.

  const http = require ( 'http' ); http . createServer ( function ( req , res ) {     // When form is submitted     if ( req . url === '/upload' && req . method === 'POST' ) {         res . writeHead ( 200 , { 'Content-Type' : 'text/html' });         res . end ( "<h2>File uploaded successfully!</h2>" );     }     else {         // Show form         res . writeHead ( 200 , { 'Content-Type' : 'text/html' });         res . end ( `             <h2>Upload File</h2>             <form action="/upload" method="post" enctype="multipart/form-data">                 Select File:<br><br>                 <input type="file" name="fileupload"><br...

Slip22 Using node js create an Employee Registration Form validation.

index.html  <!DOCTYPE html> <html> <head> <title>Employee Registration</title> </head> <body> <h1>Employee Registration Form</h1> <form action="/register" method="post"> <label>Name:</label><br> <input type="text" name="name" required><br> <label>Email:</label><br> <input type="email" name="email" required><br> <label>Password:</label><br> <input type="password" name="password" required><br> <input type="submit" value="Register"> </form> </body> </html> slip22.js const http = require('http'); const fs = require('fs'); const qs =require('querystring'); const server = http.createServer((req, res) => { if (req.method === 'GET' && req.url === '/') { // Serve HTML form fs...

Slip 10

 Write node js script to build Your Own Node.js Module. Use require (‘http’) module is a built in Node module that invokes the functionality of the HTTP library to create a local server. Also use the export statement to make functions in your module available externally. Create a new text file to contain the functions in your module called, “modules.js” and add this function to return today’s date and time. modules.js // datetime_app.js function datetime() {     let dt = new Date();     let date = ("0" + dt.getDate()).slice(-2);     let month = ("0" + (dt.getMonth() + 1)).slice(-2);     let year = dt.getFullYear();     let hours = ("0" + dt.getHours()).slice(-2);     let minutes = ("0" + dt.getMinutes()).slice(-2);     let seconds = ("0" + dt.getSeconds()).slice(-2);     let output = year + "-" + month + "-" + date +                  " " + hours + ":" + minut...