Assignment 02 Get link Facebook X Pinterest Email Other Apps July 21, 2023 // Create a Server in nodejsconst http = require('http');http.createServer(function(req,res){ res.writeHead(200,{'Content-Type':'text/html'}); res.write('Welcome Server is created!!'); res.end();}).listen(3000); Get link Facebook X Pinterest Email Other Apps Comments
Assesment SetA-1 July 21, 2023 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 } ` ); }); Read more
Assesment SetA-2 July 21, 2023 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 (... Read more
Assignment 01 July 21, 2023 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 ... Read more
Comments
Post a Comment