Posts

React for Beginners

 This course will teach you React from Scratch Node Version 18.X.X Code Editor VSCODE Prerequisite: HTML, CSS, JavaScript So Let's Start     1. Using Prettier Extension in Vs Code (code formatting)          Setting up : Format on Save, File>Preferences>Setting>Search(format on save)>check 2. There are two ways to create react app         a) Using Create-React-App(CRA) : npx create-react-app app_name          b) Using Vite :  npm create vite@latest          or          npm create vite@4.1.0 I'm Using Vite tool to create a react project:    ->   npm create vite@4.1.0     -> hit y     -> type app name and select framework and language (react-app, React, TypeScript)      -> npm install     -> To lunch the project: npm run dev dsf

How to use others API in my website?

 To Use others API to get data, first thing you need is API_KEY. Some API's are :     To get random quotes :   https://api.kanye.rest           { " quote ":  "I don't expect to be understood at all."      }           To get random Jokes  :  h ttps://v2.jokeapi.dev/joke/Any            ENDPOINT - >    https://v2.jokeapi.dev/joke / this is an endpoint for api.      To use Weather details in your website : Openweather API app . get ( "/" , function ( req , res ){     const weatherUrl = "https://api.openweathermap.org/data/2.5/weather?                                    q=Dhangadhi&appid={api_key}&units=metric" ;     https . get ( weatherUrl , function ( response ){   ...

calculator app using node express

Image
 Calculator App Q. How to get form data in express server? Ans: Use Body-Parser Module to get html form data into the server.      Example:  app . get ( "/" , function ( req , res ){     res . sendFile ( __dirname + "/index.html" ); }); app . post ( "/" , function ( req , res ){     res . send ( "Data sent !" ); }); If we wanna try to get from data we get form values in PayLoad section in Chrome Developer Tool                    Here we can see :                    firstNumber : 2                    secondNumber: 6                  these numbers are bound to forms input fields To use these information in server We Need BodyParser     > npm install body-parser Then include it in your code:     > con...

Understanding and working with Express Route

 Routes in Express Here is an example how we create multiple routes in express : const express = require ( "express" ); const app = express (); const PORT = 3000 ; app . get ( "/" , function ( req , res ){     res . send ( "<h1>Hello Express</h1>" ) }); app . get ( "/contact" , function ( req , res ){     res . send ( "Contact : <b>mayacr62@gmail.com</b>" ); }); app . get ( "/about" , function ( req , res ){     res . send ( "<h3>Hello, I am Mayaram Chaudhary. Click Me <a href='github.com/maya-cx'>GitHub</a>" ); }) app . listen ( PORT , function (){     console . log ( "Server started on port " + PORT ); }); Struggling refreshing page everytime ? Install NodeMon package which monitors the changes in you source and restart server automatically. > npm install nodemon To start nodemon > nodemon file.js and hit enter

Setup node framework | Express

Image
 First step to start with express is to install express in our project.     >  npm install express  This command will add express dependency into package.json file and download packages from internet. Let's create a new express server: const express = require ( "express" ); const app = express (); const PORT = 3000 ; app . listen ( PORT , function (){     console . log ( "Server started on port " + PORT ); });     Here is an error Cannot GET / becoz we do set the request or response from the server: app . get ( "/" , function ( request , response ){     console . log ( request ); }); We can see now all the request parameters in console. To send the response to the client :  app . get ( "/" , function ( req , res ){     res . send ( "Hello Express..." ); }); Now we can see the output that is a response from the server on / location. You can also send HTML as a response :  app . get ( "...

Node Js Setup and using built-in and external modules

Image
 Node JS 1. Use of Built-in Modules      const anyName = require(' module_name ');     Example : How to copy a file Using File System in Node Javascript.     Solution : Suppose we have a file namely file1.txt and they contain some text in it.                     const fs = require(" fs "); //includes file system module                     fs.copyFileSync("file1.txt", "file2.txt"); //copyFileSync is method to copy file                         //here file2.txt will be created with the text that inside file1.txt and if file already                                    exists it will be replaced           2. U...

BE Computer Question Paper

Old Questions Pokhara University BE Computer Seventh Semester Question 2021 Fall Computer Engineering  Download Seventh Semester Old Question Artificial Intelligence  Download   Seventh Semester Old Question Computer Network  Download   Seventh Semester Old Question Engineering Economics  Download   Seventh Semester Old Question ICT Project Management  Download   Seventh Semester Old Question Image Processing and Pattern Recognition  Download