Posts
Assesment SetA-2
- Get link
- X
- Other Apps
const http = require ( 'http' ); const studentDetails = { Id : '01' , Name : 'Zaahid' , Semester : 5 , Batch : 2023 }; const server = http . createServer (( req , res ) => { if ( req . method === 'GET' ) { res . end ( studentDetails ); console . log ( "GET" ) } else if ( req . method === 'POST' ) { let body = '' ; req . on ( 'data' , ( chunk ) => { body += chunk ; }); req . on ( 'end' , () => { res . end ( `POST request received with data: ${ body } ` ); }); } else if ( req . method === 'PUT' ) { let body = '' ; req . on ( 'data' , ( chunk ) => { body += chunk ; }); req . on ( 'end' , () => { res . end (...
Assesment SetA-1
- Get link
- X
- Other Apps
const http = require ( 'http' ); const server = http . createServer (( req , res ) => { res . setHeader ( 'Set-Cookie' , 'course_name=BCA' ); res . end ( 'Cookie "course_name" set to "BCA"' ); }); const port = 3000 ; server . listen ( port , () => { console . log ( `Server listening on port ${ port } ` ); });
Assignment 3(or 4)
- Get link
- X
- Other Apps
//01 Create a program which request the resource from the server on the // route /hello using get method as well as post method. const express = require ( 'express' ); const app = express (); app . get ( '/hello' , function ( req , res ){ res . send ( "Hello Zaahid" ) }) app . post ( '/hello' , function ( req , res ){ res . send ( "Hello Zaahid" ) }) app . listen ( 3000 ); //02 Create a program which request the resource from the server // using get, post, delete and put methods. //<---Error code dont use---> const express = require ( 'express' ); const app = express (); // app . get ( '/get' , ( req , res ) => { const studentDetails = { Id : '01' , Name : 'Zaahid' , Semester : 5 , Batch : 2023 }; res . send ( studentDetails ); console . log ( "Get" ); }); // app . post ( '/post' , ( req , res ) => { ...
Assignment 2.1
- Get link
- X
- Other Apps
//01 var express = require ( 'express' ); var app = express (); app . get ( '/' , function ( req , res ){ res . send ( "Hello World" ) }) //02 const express = require ( 'express' ); const app = express (); const port = 3000 app . get ( '/' , function ( req , res ){ res . send ( "Hello World" ) }) app . listen ( port ,() => { console . log ( 'app listenting example on port ${port}' ) }) //03 const express = require ( 'express' ); const app = express (); const port = 3000 app . get ( '/hello' , function ( req , res ){ res . send ( "Hello Zaahid" ) }) app . post ( '/hello' , function ( req , res ){ res . send ( "Hello Zaahid" ) }) app . listen ( port ); //04 var express = require ( 'express' ); var app = express (); var things = require ( './things' ); app . use ( '/things' , things ); app . listen ( 3000 ); /...
Assignment 01
- Get link
- X
- Other Apps
const os = require ( 'os' ); const fs = require ( 'fs' ); const chalk = require ( 'chalk' ); //Install it 1st command is-- npm install chalk@4.1.2 //01 console . log ( 'Hello world' ); //02 console . log ( chalk . green ( 'Hello World' )); //03 var add = ( num1 , num2 ) => num1 + num2 ; console . log ( add ( 3 , 4 )); //04 os information console . log ( os . platform ()); console . log ( os . release ()); //05 file read (must have a txt file in same folder named text.txt) fs . readFile ( 'text.txt' , 'utf8' , ( err , data ) => { if ( err ) { console . error ( 'Error reading file:' , err ); return ; } console . log ( data ); }); //06 odd even with color function evenodd ( x ) { if ( x % 2 == 0 ) { console . log ( chalk . green ( "even" )) } else { console . log ( chalk . red ( "odd" )) } } evenodd ( 23 ) evenodd ( 24 ) //07 swap number let a = 5 ; let ...