Posts

Showing posts from November, 2022

Node JS - Make HTML page

index3.js -    const express = require ( 'express' ); const path = require ( 'path' ); const app = express (); const publicPath = path . join ( __dirname , 'public' ); console . log ( publicPath ); app . use ( express . static ( publicPath )); app . listen ( 5000 ); -------------------------------------- index.html (under public folder) <!DOCTYPE html > <html lang = "en" > <head>     <title> Home Page </title> </head> <body>     <h1> Home Page Node JS </h1> </body> </html> ------------------------------------ about.html (under public folder) <!DOCTYPE html > <html lang = "en" > <head>         <title> About Us Page </title> </head> <body>     <h2> About Us Page </h2>     <p> Lorem, ipsum dolor sit amet consectetur adipisicing elit. Dolor fugit tenetur ex doloremque quis expedita dignissimos tempore officia! Volu

Express JS - Render HTML and JSON

  const express = require ( 'express' ); const app = express (); app . get ( '' , ( req , resp ) => {     // console.log("Data sent by Browser =>", req.query.name)     // resp.send('Hello, this is a home page');     resp . send ( `     <h1>Jai Sri Krishna</h1>     <a href="/about">Go to About Page</a>     ` ); }); app . get ( '/about' , ( req , resp ) => {     // resp.send('Hello, this is a about page');     resp . send ( `     [         {             name:'krishan',             email:'krishan@gmail.com'         },         {             name:'Radhe',             email:'radhe@gmail.com'         }             ]     <a href="/">Go to Home Page</a>     ` ); }); app . listen ( 5000 );

Express JS Example

  const express = require ( 'express' ); const app = express (); app . get ( '' , ( req , resp ) => {     resp . send ( 'Hello, this is a home page' ); }); app . get ( '/about' , ( req , resp ) => {     resp . send ( 'Hello, this is a about page' ); }); app . listen ( 5000 );

Node.js CRUD with File System

  const fs = require ( 'fs' ); const path = require ( 'path' ); const dirPath = path . join ( __dirname , 'crud' ); const filePath = ` ${ dirPath } /apple.txt` ; // fs.writeFileSync(filePath, 'this is a apple.txt file'); // fs.readFile(filePath,'utf8', (err, item)=>{ //     console.log(item) // }) // fs.appendFile(filePath, 'I am updating apple.txt file', (err)=>{ //     if(!err){ //         console.log("file is updated") //     } // }) // fs.rename(filePath, `${dirPath}/fruit.txt`, (err)=>{ //     if(!err){ //         console.log("File name has been renamed") //     } // }) fs . unlinkSync ( ` ${ dirPath } /fruit.txt` )

Node Js API Tutorial 2022

Image
 First Static API: -  api1.js -  const http = require ( 'http' ); const data = require ( './data' ); http . createServer (( req , resp ) => {     resp . writeHead ( 200 , { 'Content-Type' : 'application \j son' });     resp . write ( JSON . stringify ( data ));     resp . end (); }). listen ( 5000 ); -------------------------------------------- data.js : - const data =[     { name : 'krishan Dev' , email : 'krishandev.0102@gmail.com' },     { name : 'Raj Dev' , email : 'rajdev.0102@gmail.com' },     { name : 'Brijesh Dev' , email : 'brijeshdev.0102@gmail.com' },     { name : 'Bhavesh Dev' , email : 'bhaveshdev.0102@gmail.com' } ] module . exports = data ; Output:

Angular Website Template

Image
 HTML -  <div id = "header" >     <div class = "container" >         <div class = "row" >             <div class = "col-md-4" >                 <h2> Company Name </h2>             </div>             <div class = "col-sm-8" >             <ul id = "menu" class = "float-md-right" >                 <a href = "" ><li> Home </li></a>                 <a href = "" ><li> About </li></a>                 <a href = "" ><li> Services </li></a>                 <a href = "" ><li> Contact </li></a>                 <a href = "" ><li> Blog </li></a>             </ul>             </div>         </div>     </div> </div> <!-- Banner --> <div id = "banner"