diff --git a/Back-End/Node.js/ViewEngine.md b/Back-End/Node.js/ViewEngine.md deleted file mode 100644 index 77c9a5c..0000000 --- a/Back-End/Node.js/ViewEngine.md +++ /dev/null @@ -1,93 +0,0 @@ -# ejs view Engine - -EJS stands for Embedded JavaScript - which means you can pull JS from the server to dynamically create page elements. - ------------- -``` - - - - - - View Engine Demo - - - - --> -

<%= title %>

- - --> - <% if(true){ %> -

hi everyone

- <% } %> - - - - -``` ----------------------------- - -EJS lets you use that loop to dynamically write HTML to the page. On the client side, if a user views source, all they see is the fully rendered page - they don’t see what kind of object was passed or how the page was constructed. -passing data - - -#### here we need to view multiple blog content so we use ejs to loop in and make much easier to render in the page - - -------------------------------- - - - ----------------------------------- - - - --------------------------------------- - - - -# partials - -When using the default view engine (ejs), Sails supports the use of partials (i.e. "view partials"). Partials are basically just views that are designed to be used from within other views. - -They are particularly useful for reusing the same markup between different views, layouts, and even other partials. - - -``` -<%- partial('./partials/navbar.ejs') %> -``` -### Notes - - Partials are rendered synchronously, so they will block Sails from serving more requests until they're done loading. It's something to keep in mind while developing your app, especially if you anticipate a large number of connections. - - Built-in support for partials in Sails is only for the default view engine, ejs. If you decide to customize your Sails install and use a view engine other than ejs, then please be aware that support for partials (sometimes known as "blocks", "includes", etc.) may or may not be included, and that the usage will vary. Refer to the documentation for your view engine of choice for more information on its syntax and conventions. - - - -# add css - - -``` -import path from 'path'; -import {fileURLToPath} from 'url'; - -const express = require('express'); -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); -const app = express(); - -app.use(express.static(path.join(__dirname, 'public'))); - -app.set('view engine', 'ejs'); - -app.get('/', (req, res) => { - res.render('home', { - title: 'bobbyhadz.com', - message: 'Example message: bobbyhadz.com', - salary: 500, - }); -}); - -``` diff --git a/Back-End/Node.js/ViewEngine/Screenshot (196).png b/Back-End/Node.js/ViewEngine/Screenshot (196).png deleted file mode 100644 index bdff199..0000000 Binary files a/Back-End/Node.js/ViewEngine/Screenshot (196).png and /dev/null differ diff --git a/Back-End/Node.js/ViewEngine/Screenshot (197).png b/Back-End/Node.js/ViewEngine/Screenshot (197).png deleted file mode 100644 index ce9970e..0000000 Binary files a/Back-End/Node.js/ViewEngine/Screenshot (197).png and /dev/null differ diff --git a/Back-End/Node.js/ViewEngine/ViewEngine.md b/Back-End/Node.js/ViewEngine/ViewEngine.md deleted file mode 100644 index 77c9a5c..0000000 --- a/Back-End/Node.js/ViewEngine/ViewEngine.md +++ /dev/null @@ -1,93 +0,0 @@ -# ejs view Engine - -EJS stands for Embedded JavaScript - which means you can pull JS from the server to dynamically create page elements. - ------------- -``` - - - - - - View Engine Demo - - - - --> -

<%= title %>

- - --> - <% if(true){ %> -

hi everyone

- <% } %> - - - - -``` ----------------------------- - -EJS lets you use that loop to dynamically write HTML to the page. On the client side, if a user views source, all they see is the fully rendered page - they don’t see what kind of object was passed or how the page was constructed. -passing data - - -#### here we need to view multiple blog content so we use ejs to loop in and make much easier to render in the page - - -------------------------------- - - - ----------------------------------- - - - --------------------------------------- - - - -# partials - -When using the default view engine (ejs), Sails supports the use of partials (i.e. "view partials"). Partials are basically just views that are designed to be used from within other views. - -They are particularly useful for reusing the same markup between different views, layouts, and even other partials. - - -``` -<%- partial('./partials/navbar.ejs') %> -``` -### Notes - - Partials are rendered synchronously, so they will block Sails from serving more requests until they're done loading. It's something to keep in mind while developing your app, especially if you anticipate a large number of connections. - - Built-in support for partials in Sails is only for the default view engine, ejs. If you decide to customize your Sails install and use a view engine other than ejs, then please be aware that support for partials (sometimes known as "blocks", "includes", etc.) may or may not be included, and that the usage will vary. Refer to the documentation for your view engine of choice for more information on its syntax and conventions. - - - -# add css - - -``` -import path from 'path'; -import {fileURLToPath} from 'url'; - -const express = require('express'); -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); -const app = express(); - -app.use(express.static(path.join(__dirname, 'public'))); - -app.set('view engine', 'ejs'); - -app.get('/', (req, res) => { - res.render('home', { - title: 'bobbyhadz.com', - message: 'Example message: bobbyhadz.com', - salary: 500, - }); -}); - -``` diff --git a/Back-End/Node.js/client&server.md b/Back-End/Node.js/client&server.md deleted file mode 100644 index 4b0acd0..0000000 --- a/Back-End/Node.js/client&server.md +++ /dev/null @@ -1,47 +0,0 @@ -# ip address and domain - - - -in node we manually create server to request from browser -actively for request and response to it -to require a core http module -use method -call back function gonna run every time a request - - ---------------------------- - - -# creatimg a server - - - -comes in in our server -get access to two different object req and res -req ->example www.anywebsite.com/about -res->it will re direct me to about page -we have to invoke the listen method -we need to pass in an argument into this - - ----------------------------- - - -# localhost and port number - - - -port number we goin listen to two argument server.listen -3000 ,local host this is the default value to -local host like domain name on the web -spceific ip address called a loop back ip adress -127.0.0.1 -request it and going back to your computer -acting as a host for our website -a port number is like a specif channel or port on your computer -that server should communicate through - - - - - diff --git a/Back-End/Node.js/client&server/client&server.md b/Back-End/Node.js/client&server/client&server.md deleted file mode 100644 index 4e21168..0000000 --- a/Back-End/Node.js/client&server/client&server.md +++ /dev/null @@ -1,44 +0,0 @@ -# ip address and domain - - -in node we manually create server to request from browser -actively for request and response to it -to require a core http module -use method -call back function gonna run every time a request - - ---------------------------- - - -# creatimg a server - - -comes in in our server -get access to two different object req and res -req ->example www.anywebsite.com/about -res->it will re direct me to about page -we have to invoke the listen method -we need to pass in an argument into this - - ----------------------------- - - -# localhost and port number - - -port number we goin listen to two argument server.listen -3000 ,local host this is the default value to -local host like domain name on the web -spceific ip address called a loop back ip adress -127.0.0.1 -request it and going back to your computer -acting as a host for our website -a port number is like a specif channel or port on your computer -that server should communicate through - - - - - diff --git a/Back-End/Node.js/express Apps.md b/Back-End/Node.js/express Apps.md deleted file mode 100644 index 4c7cc52..0000000 --- a/Back-End/Node.js/express Apps.md +++ /dev/null @@ -1,109 +0,0 @@ -# what is express - ->Express.js is a small framework that works on top of Node.js web server functionality ->Develops Node.js web applications quickly and easily.you can use raw node as we discuss in previous lessons but express is more organized and defined code instead of > raw node ->Allows you to define application routes using HTTP methods and URLs. ->Allows you to specify a middleware for handling errors. - ----------------------------------------- - - - -``` -$ mkdir gfg -$ cd gfg -``` - -######gfgf->file name - - - -``` -$ npm init - -``` - -``` -$ npm install express --save -``` - - -# creating an express app - - - -``` -const express = require('express'); -const app = express(); -app.listen(3000); -app.get('/', (req, res) =>{ -res.send("Welocme !"); -}); - -``` - -# routing and html pages - - - we can do that by adding multiple of these ```app.get()``` command get - handlers - - - - -``` -const express = require('express'); -const app = express(); -app.listen(3000); -app.get('/', (req, res) =>{ -res.sendFile('./index.html',{root:__dirname}); -}); - -app.get('/about', (req, res) =>{ -res.sendFile(./about.html',{root:__dirname}); -}); - - - - -``` - -## Note - ->the directory is relative path not absolute so we need to handle this situation by adding the {root:__dirname} - - - -# redirecting and 404 pages - -we need to handle a 404 case - ->by using method called use ->we will know about use and middleware more in upcoming lessons ->but now we will use it to handle 404 case - - - - -``` -const express = require('express'); -const app = express(); -app.listen(3000); -app.get('/', (req, res) =>{ -res.sendFile('./index.html',{root:__dirname}); -}); - -app.get('/about', (req, res) =>{ -res.sendFile(./about.html',{root:__dirname}); -}); - -app.use((req,res)=>{ -res.sendFile(./404.html',{root:__dirname}); -}) - - -``` - ->use function is going fire for every single request coming in ->but only if the request reaches this point in the code - diff --git a/Back-End/Node.js/Screenshot (196).png b/Back-End/Node.js/express/Screenshot (196).png similarity index 100% rename from Back-End/Node.js/Screenshot (196).png rename to Back-End/Node.js/express/Screenshot (196).png diff --git a/Back-End/Node.js/Screenshot (197).png b/Back-End/Node.js/express/Screenshot (197).png similarity index 100% rename from Back-End/Node.js/Screenshot (197).png rename to Back-End/Node.js/express/Screenshot (197).png diff --git a/Back-End/Node.js/expressApp/express Apps.md b/Back-End/Node.js/express/expressApp/express Apps.md similarity index 88% rename from Back-End/Node.js/expressApp/express Apps.md rename to Back-End/Node.js/express/expressApp/express Apps.md index a0faf28..8c09ae7 100644 --- a/Back-End/Node.js/expressApp/express Apps.md +++ b/Back-End/Node.js/express/expressApp/express Apps.md @@ -99,5 +99,5 @@ res.sendFile(./404.html',{root:__dirname}); ``` ->use function is going fire for every single request coming in ->but only if the request reaches this point in the code +>use function is going fir for every single request coming in +>but only if the request reaches this point in the \ No newline at end of file diff --git a/Back-End/Node.js/middleware.md b/Back-End/Node.js/express/middleWare/middleware.md similarity index 100% rename from Back-End/Node.js/middleware.md rename to Back-End/Node.js/express/middleWare/middleware.md diff --git a/Back-End/Node.js/express/readme.md b/Back-End/Node.js/express/readme.md new file mode 100644 index 0000000..eb1d196 --- /dev/null +++ b/Back-End/Node.js/express/readme.md @@ -0,0 +1,274 @@ +# 3rd party packages + +packages that is not part of the core Node.js library. These dependencies can be used to add new features to your Node.js application, or to improve the performance or reliability of your application. + + +installing packages globally + +for example To install a third-party dependency, you can use the npm install command + +``` +npm install express + +``` + +the packages .json file and installing +packages locally + +after installing the packages you should definitely create a package JSON file + by typing into terminal +``` +npm init +``` + + >this initializes as a package JSON file + > then series of questions will appear asking about project and it give a default value + + >you can override those by typing in a new one + >then the file is created in your files of nodejs project + +# another example install a upper case package + +``` +npm install upper-case + +``` + + +------------------------- + + +``` + var http = require('http'); +var uc = require('upper-case'); +http.createServer(function (req, res) { + res.writeHead(200, {'Content-Type': 'text/html'}); + res.write(uc.upperCase("Hello World!")); + res.end(); +}).listen(8080); + +``` +------------------------------------ + + +>Save the code above in a file called "demo_uppercase.js", and initiate the file: + + + +------------------------------------- + + +``` +C:\Users\Your Name>node demo_uppercase.js + +``` + + # dependencies and sharing code + +the sharing of the code will be hard as load of different packages and dependencies inside it +send them or upload them you aren't going to see node modules folders +if you delete the file "node modules" and run it ,you get an error +then you have to install all of the different packages the project uses + + +# what is express + +>Express.js is a small framework that works on top of Node.js web server functionality +>Develops Node.js web applications quickly and easily.you can use raw node as we discuss in previous lessons but express is more organized and defined code instead of > raw node +>Allows you to define application routes using HTTP methods and URLs. +>Allows you to specify a middleware for handling errors. + +---------------------------------------- + + +``` +$ mkdir gfg +$ cd gfg +``` + +######gfg->file name + + +``` +$ npm init + +``` + +``` +$ npm install express --save +``` + + +# creating an express app + + +``` +const express = require('express'); +const app = express(); +app.listen(3000); +app.get('/', (req, res) =>{ +res.send("Welocme !"); +}); + +``` + +# routing and html pages + + + we can do that by adding multiple of these ```app.get()``` command get + handlers + + + +``` +const express = require('express'); +const app = express(); +app.listen(3000); +app.get('/', (req, res) =>{ +res.sendFile('./index.html',{root:__dirname}); +}); + +app.get('/about', (req, res) =>{ +res.sendFile(./about.html',{root:__dirname}); +}); + + + + +``` + +## Note + +>the directory is relative path not absolute so we need to handle this situation by adding the {root:__dirname} + + + +# redirecting and 404 pages + +we need to handle a 404 case + +>by using method called use +>we will know about use and middleware more in upcoming lessons +>but now we will use it to handle 404 case + + + +``` +const express = require('express'); +const app = express(); +app.listen(3000); +app.get('/', (req, res) =>{ +res.sendFile('./index.html',{root:__dirname}); +}); + +app.get('/about', (req, res) =>{ +res.sendFile(./about.html',{root:__dirname}); +}); + +app.use((req,res)=>{ +res.sendFile(./404.html',{root:__dirname}); +}) + + +``` + +>use function is going fir for every single request coming in +>but only if the request reaches this point in the + + + + + +# ejs view Engine + +EJS stands for Embedded JavaScript - which means you can pull JS from the server to dynamically create page elements. + +------------ +``` + + + + + + View Engine Demo + + + + --> +

<%= title %>

+ + --> + <% if(true){ %> +

hi everyone

+ <% } %> + + + + +``` +---------------------------- + +EJS lets you use that loop to dynamically write HTML to the page. On the client side, if a user views source, all they see is the fully rendered page - they don’t see what kind of object was passed or how the page was constructed. +passing data + + +#### here we need to view multiple blog content so we use ejs to loop in and make much easier to render in the page + + +------------------------------- + + + +---------------------------------- + + + +-------------------------------------- + + + +# partials + +When using the default view engine (ejs), Sails supports the use of partials (i.e. "view partials"). Partials are basically just views that are designed to be used from within other views. + +They are particularly useful for reusing the same markup between different views, layouts, and even other partials. + + +``` +<%- partial('./partials/navbar.ejs') %> +``` +### Notes + + Partials are rendered synchronously, so they will block Sails from serving more requests until they're done loading. It's something to keep in mind while developing your app, especially if you anticipate a large number of connections. + + Built-in support for partials in Sails is only for the default view engine, ejs. If you decide to customize your Sails install and use a view engine other than ejs, then please be aware that support for partials (sometimes known as "blocks", "includes", etc.) may or may not be included, and that the usage will vary. Refer to the documentation for your view engine of choice for more information on its syntax and conventions. + + + +# add css + + +``` +import path from 'path'; +import {fileURLToPath} from 'url'; + +const express = require('express'); +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const app = express(); + +app.use(express.static(path.join(__dirname, 'public'))); + +app.set('view engine', 'ejs'); + +app.get('/', (req, res) => { + res.render('home', { + title: 'bobbyhadz.com', + message: 'Example message: bobbyhadz.com', + salary: 500, + }); +}); + +``` diff --git a/Back-End/Node.js/http.md b/Back-End/Node.js/http module/readme.md similarity index 100% rename from Back-End/Node.js/http.md rename to Back-End/Node.js/http module/readme.md diff --git a/Back-End/Node.js/http/http.md b/Back-End/Node.js/http/http.md deleted file mode 100644 index 0eb06ac..0000000 --- a/Back-End/Node.js/http/http.md +++ /dev/null @@ -1,55 +0,0 @@ -# HTTP Module ->now lest discuss what **http** module is built-in module called HTTP ->allows Nodejs to transfer data over the Hyper Text transfer protocol ---- -to include the http module use the ```require ()``` method : -``` -var http =require ('http'); -//create a server object : -http.createServer(function(req,res){ - res.write('hello World!' ); - res.end(); - -}).listen(8080); - - -``` ---- -To create an HTTP server, call the ```http.createServer()``` function. It accepts a single -argument, a callback function, that will be called on each HTTP request received by -the server. This request callback receives, as arguments, the request and response objects ---- -# Read The Query String - -``` -var http = require('http'); -http.createServer(function (req, res) { - res.writeHead(200, {'Content-Type': 'text/html'}); - res.write(req.url); - res.end(); -}).listen(8080); - - - -``` ---- -let's summarize this journey - - -1.An HTTP client, like a web browser,initiates an HTTP. - - -2.Node accepts the connection,and incoming request data is given to the HTTP server. - - -3.The HTTP server parses up to the end of the HTTP headers and then hands control over to the request callback. - - -4.The request callback performs application logic, in this case responding immediately with the text “Hello World”. - - -5.The request is sent back through the HTTP server, which formats a proper HTTP response for the client. - - ---- - diff --git a/Back-End/Node.js/README.md b/Back-End/Node.js/introduction to Node.js/README.md old mode 100755 new mode 100644 similarity index 94% rename from Back-End/Node.js/README.md rename to Back-End/Node.js/introduction to Node.js/README.md index 18cb329..8e0fe2e --- a/Back-End/Node.js/README.md +++ b/Back-End/Node.js/introduction to Node.js/README.md @@ -6,15 +6,15 @@ - ## Why Node.js - - Javascript + - JavaScript > Can be a curse or a blessing depending on what language you are comfortable with. - + - `npm` (Node Package Manager) > In January 2017 over 350000 packages were reported being listed in the npm registry, making it the biggest single language code repository on Earth, and you can be sure there is a package for (almost!) everything. - - Ability to keep data in native JSON (javascript object notation) format. + - Ability to keep data in native JSON (JavaScript object notation) format. - Wide range of hosting options. @@ -49,11 +49,11 @@ To run this snippet, save it as a `server.js` file and run `node server.js` in your terminal. - ![run command](./Docs/nodejs-server-run.png) + ![run command](nodejs-server-run.png) Firefox browser output: - ![server output](./Docs/nodejs-server-output.png) + ![server output](nodejs-server-output.png) To include `http` module: diff --git a/Back-End/Node.js/Docs/javascript-the-good-parts.jpg b/Back-End/Node.js/introduction to Node.js/javascript-the-good-parts.jpg similarity index 100% rename from Back-End/Node.js/Docs/javascript-the-good-parts.jpg rename to Back-End/Node.js/introduction to Node.js/javascript-the-good-parts.jpg diff --git a/Back-End/Node.js/Docs/nodejs-server-output.png b/Back-End/Node.js/introduction to Node.js/nodejs-server-output.png old mode 100755 new mode 100644 similarity index 100% rename from Back-End/Node.js/Docs/nodejs-server-output.png rename to Back-End/Node.js/introduction to Node.js/nodejs-server-output.png diff --git a/Back-End/Node.js/Docs/nodejs-server-run.png b/Back-End/Node.js/introduction to Node.js/nodejs-server-run.png old mode 100755 new mode 100644 similarity index 100% rename from Back-End/Node.js/Docs/nodejs-server-run.png rename to Back-End/Node.js/introduction to Node.js/nodejs-server-run.png diff --git a/Back-End/Node.js/modules.md b/Back-End/Node.js/modules/basic_modules/readme.md similarity index 100% rename from Back-End/Node.js/modules.md rename to Back-End/Node.js/modules/basic_modules/readme.md diff --git a/Back-End/Node.js/npm.md b/Back-End/Node.js/npm.md deleted file mode 100644 index 9e6204f..0000000 --- a/Back-End/Node.js/npm.md +++ /dev/null @@ -1,76 +0,0 @@ -# 3rd party packages - - -packages that is not part of the core Node.js library. These dependencies can be used to add new features to your Node.js application, or to improve the performance or reliability of your application. - - -installing packages globally - -for example To install a third-party dependency, you can use the npm install command - -``` -npm install express - -``` - -the packages .json file and installing -packages locally - -after installing the packages you should definitely create a package JSON file - by typing into terminal -``` -npm init -``` - - >this initializes as a package JSON file - > then series of questions will appear asking about project and it give a default value - - >you can override those by typing in a new one - >then the file is created in your files of nodejs project - -# another example install a upper case package - - -``` -C:\Users\Your Name>npm install upper-case - -``` - - -------------------------- - - - -``` - var http = require('http'); -var uc = require('upper-case'); -http.createServer(function (req, res) { - res.writeHead(200, {'Content-Type': 'text/html'}); - res.write(uc.upperCase("Hello World!")); - res.end(); -}).listen(8080); - -``` ------------------------------------- - - ->Save the code above in a file called "demo_uppercase.js", and initiate the file: - - - -------------------------------------- - - - -``` -C:\Users\Your Name>node demo_uppercase.js - -``` - - # dependencies and sharing code - - -the sharing of the code will be hard as load of different packages and dependencies inside it -send them or upload them you aren't going to see node modules folders -if you delete the file "node modules" and run it ,you get an error -then you have to install all of the different packages the project uses diff --git a/Back-End/Node.js/npm/npm.md b/Back-End/Node.js/npm/npm.md deleted file mode 100644 index ab19fb8..0000000 --- a/Back-End/Node.js/npm/npm.md +++ /dev/null @@ -1,71 +0,0 @@ -# 3rd party packages - -packages that is not part of the core Node.js library. These dependencies can be used to add new features to your Node.js application, or to improve the performance or reliability of your application. - - -installing packages globally - -for example To install a third-party dependency, you can use the npm install command - -``` -npm install express - -``` - -the packages .json file and installing -packages locally - -after installing the packages you should definitely create a package JSON file - by typing into terminal -``` -npm init -``` - - >this initializes as a package JSON file - > then series of questions will appear asking about project and it give a default value - - >you can override those by typing in a new one - >then the file is created in your files of nodejs project - -# another example install a upper case package - -``` -C:\Users\Your Name>npm install upper-case - -``` - - -------------------------- - - -``` - var http = require('http'); -var uc = require('upper-case'); -http.createServer(function (req, res) { - res.writeHead(200, {'Content-Type': 'text/html'}); - res.write(uc.upperCase("Hello World!")); - res.end(); -}).listen(8080); - -``` ------------------------------------- - - ->Save the code above in a file called "demo_uppercase.js", and initiate the file: - - - -------------------------------------- - - -``` -C:\Users\Your Name>node demo_uppercase.js - -``` - - # dependencies and sharing code - -the sharing of the code will be hard as load of different packages and dependencies inside it -send them or upload them you aren't going to see node modules folders -if you delete the file "node modules" and run it ,you get an error -then you have to install all of the different packages the project uses diff --git a/Back-End/Node.js/request&response/request&response .md b/Back-End/Node.js/request&response/request&response .md deleted file mode 100644 index 5447074..0000000 --- a/Back-End/Node.js/request&response/request&response .md +++ /dev/null @@ -1,179 +0,0 @@ -# request object - - - -lets investigate request object more closer - ------------------------ - - -``` -const server= http.createServer((req,res)=>{ - console.log(req); -}); - -``` - - - >in the terminal will load different things of object it contains headers ,response type,URL(the user has visited) - - -``` -const server= http.createServer((req,res)=>{ - console.log(req.url,req.method); -}); - -``` - -> /the root of the website ,the method is GET request - -# response object - -we want to formulate some kind of response for the request of the user by the browser -first thing first is to formulate the response headers give the browser "what kind of response is coming back to it " -(text -html -json .... etc ) -also headers can set cookies - ----------------------------------------- - -``` -const server= http.createServer((req,res)=>{ - console.log(req.url,req.method); - res.setHeader('Content-Type','text/plain'); - res.write('hello'); - res.end(); -}); - -``` - -------------------------------------- - - - -``` -const server= http.createServer((req,res)=>{ - console.log(req.url,req.method); - res.setHeader('Content-Type','text/html'); - res.write(

'hello'

); - res.end(); -}); - -``` - - ->returning html pages - ->lets be more defined and instead of returing resonse with the tags or plain text ,return html page - - - -``` -const fs=require ('fs'); -const server= http.createServer((req,res)=>{ - console.log(req.url,req.method); - res.setHeader('Content-Type','text/html'); - fs.readFile('./index.html',(err,data)=>{ - if(err){ - console.log(err); - res.end(); - } - else{ - - res.end(data); - } - }) -}); - -``` - -# basic routing - - - now we have a lot of route directory to handle it - -``` -const fs=require ('fs'); -const server= http.createServer((req,res)=>{ - console.log(req.url,req.method); - res.setHeader('Content-Type','text/html'); - let path='/file'; - switch(req.url){ - case'/': - path+='index.html'; - break; - case'/about': - path+='about.html'; - break; - default: - path+='404.html'; - break; - } - - fs.readFile('./index.html',(err,data)=>{ - if(err){ - console.log(err); - res.end(); - } - else{ - - res.end(data); - } - }) -}); - -``` - - -# status code - - -status code describe the type of response sent to the browser - - ->200 = ok ->301 = resource moved ->404-not found ->500-internal server error - -### lets try this - - -``` -const fs=require ('fs'); -const server= http.createServer((req,res)=>{ - console.log(req.url,req.method); - res.setHeader('Content-Type','text/html'); - let path='/file'; - switch(req.url){ - case'/': - path+='index.html'; - res.statusCode=200; - break; - case'/about': - path+='about.html'; - res.statusCode=200; - break; - default: - path+='404.html'; - res.statusCode=404; - break; - } - - fs.readFile('./index.html',(err,data)=>{ - if(err){ - console.log(err); - res.end(); - } - else{ - - res.end(data); - } - }) -}); - -``` - -try to redirect your response ;) - - - diff --git a/Back-End/Node.js/request&response .md b/Back-End/Node.js/streams/readme.md similarity index 72% rename from Back-End/Node.js/request&response .md rename to Back-End/Node.js/streams/readme.md index b2a6a31..199fadb 100644 --- a/Back-End/Node.js/request&response .md +++ b/Back-End/Node.js/streams/readme.md @@ -1,3 +1,45 @@ +# ip address and domain + + +in node we manually create server to request from browser +actively for request and response to it +to require a core http module +use method +call back function gonna run every time a request + + +--------------------------- + + +# creatimg a server + + +comes in in our server +get access to two different object req and res +req ->example www.anywebsite.com/about +res->it will re direct me to about page +we have to invoke the listen method +we need to pass in an argument into this + + +---------------------------- + + +# localhost and port number + + +port number we goin listen to two argument server.listen +3000 ,local host this is the default value to +local host like domain name on the web +spceific ip address called a loop back ip adress +127.0.0.1 +request it and going back to your computer +acting as a host for our website +a port number is like a specif channel or port on your computer +that server should communicate through + + + # request object @@ -7,7 +49,6 @@ lets investigate request object more closer ----------------------- - ``` const server= http.createServer((req,res)=>{ console.log(req); @@ -19,7 +60,6 @@ const server= http.createServer((req,res)=>{ >in the terminal will load different things of object it contains headers ,response type,URL(the user has visited) - ``` const server= http.createServer((req,res)=>{ console.log(req.url,req.method); @@ -31,7 +71,6 @@ const server= http.createServer((req,res)=>{ # response object - we want to formulate some kind of response for the request of the user by the browser first thing first is to formulate the response headers give the browser "what kind of response is coming back to it " (text -html -json .... etc ) @@ -70,7 +109,6 @@ const server= http.createServer((req,res)=>{ - ``` const fs=require ('fs'); const server= http.createServer((req,res)=>{ @@ -93,7 +131,6 @@ const server= http.createServer((req,res)=>{ # basic routing - now we have a lot of route directory to handle it ``` @@ -143,7 +180,6 @@ status code describe the type of response sent to the browser ### lets try this - ``` const fs=require ('fs'); const server= http.createServer((req,res)=>{ @@ -179,7 +215,6 @@ const server= http.createServer((req,res)=>{ ``` - try to redirect your response ;) diff --git a/Back-End/Node.js/viewEngine b/Back-End/Node.js/viewEngine deleted file mode 100644 index 8b13789..0000000 --- a/Back-End/Node.js/viewEngine +++ /dev/null @@ -1 +0,0 @@ - diff --git a/JavaScript/JavaScript_Session-1.pptx b/Javascript/Session 1/JavaScript_Session-1.pptx similarity index 100% rename from JavaScript/JavaScript_Session-1.pptx rename to Javascript/Session 1/JavaScript_Session-1.pptx diff --git a/Javascript/Session 2/Hands On.html b/Javascript/Session 2/Hands On.html new file mode 100644 index 0000000..c092cee --- /dev/null +++ b/Javascript/Session 2/Hands On.html @@ -0,0 +1,30 @@ + + + + + +

JavaScript Timing

+ +

A script on this page starts this clock:

+ +

+ + + + + + + + + \ No newline at end of file diff --git a/JavaScript/JavaScript_Session-2.pptx b/Javascript/Session 2/JavaScript_Session-2.pptx similarity index 89% rename from JavaScript/JavaScript_Session-2.pptx rename to Javascript/Session 2/JavaScript_Session-2.pptx index 0be3ef0..ff30f69 100644 Binary files a/JavaScript/JavaScript_Session-2.pptx and b/Javascript/Session 2/JavaScript_Session-2.pptx differ diff --git a/Javascript/Session 2/example 1.html b/Javascript/Session 2/example 1.html new file mode 100644 index 0000000..709ec7b --- /dev/null +++ b/Javascript/Session 2/example 1.html @@ -0,0 +1,21 @@ + + + + + My Page + + + +
+

first paragraph

+

second paragraph

+

third paragraph

+
+ + + + + + \ No newline at end of file diff --git a/Javascript/Session 2/example 2.html b/Javascript/Session 2/example 2.html new file mode 100644 index 0000000..c76289a --- /dev/null +++ b/Javascript/Session 2/example 2.html @@ -0,0 +1,39 @@ + + + + + My Page + + + +
+

first paragraph

+

second paragraph

+

third paragraph

+
+ +
+

another temperory div.

+ google photo +

Lorem ipsum dolor sit amet consectetur, adipisicing elit. Rerum ipsum molestiae libero necessitatibus dolorum tempora, blanditiis ducimus nobis voluptate totam deleniti ex earum expedita eos provident atque ratione quibusdam soluta.

+ +
+
+
+
+

+ +
+
+ + + + + + \ No newline at end of file diff --git a/Javascript/Session 2/example 3.html b/Javascript/Session 2/example 3.html new file mode 100644 index 0000000..5fea77e --- /dev/null +++ b/Javascript/Session 2/example 3.html @@ -0,0 +1,19 @@ + + + + + My Page + + + +

click this text please.

+ + + + + + \ No newline at end of file diff --git a/Javascript/Session 2/example 4.html b/Javascript/Session 2/example 4.html new file mode 100644 index 0000000..d876824 --- /dev/null +++ b/Javascript/Session 2/example 4.html @@ -0,0 +1,16 @@ + + + + + My Page + + + +

click this text please.

+ + + + + \ No newline at end of file diff --git a/Javascript/Session 2/example 5.html b/Javascript/Session 2/example 5.html new file mode 100644 index 0000000..a144076 --- /dev/null +++ b/Javascript/Session 2/example 5.html @@ -0,0 +1,23 @@ + + + + + My Page + + + +
+

first paragraph

+

second paragraph

+

third paragraph

+
+ + + + \ No newline at end of file diff --git a/Javascript/Session 2/example 6.html b/Javascript/Session 2/example 6.html new file mode 100644 index 0000000..c7f2a70 --- /dev/null +++ b/Javascript/Session 2/example 6.html @@ -0,0 +1,23 @@ + + + + + My Page + + + +

Big Title

+
+ google photo +

Lorem ipsum dolor sit amet consectetur adipisicing elit. Impedit, voluptate cumque? Mollitia fuga non voluptate officia possimus necessitatibus, voluptatibus minus dolor soluta sunt unde, omnis aliquam vel dolores. Iusto, autem!

+
+ + + + + \ No newline at end of file diff --git a/Javascript/Session 2/example 7.html b/Javascript/Session 2/example 7.html new file mode 100644 index 0000000..d331f3a --- /dev/null +++ b/Javascript/Session 2/example 7.html @@ -0,0 +1,23 @@ + + + + + My Page + + + +

Big Title

+
+ google photo +

Lorem ipsum dolor sit amet consectetur adipisicing elit. Impedit, voluptate cumque? Mollitia fuga non voluptate officia possimus necessitatibus, voluptatibus minus dolor soluta sunt unde, omnis aliquam vel dolores. Iusto, autem!

+
+ + + + + \ No newline at end of file diff --git a/Javascript/Session 2/example 8.html b/Javascript/Session 2/example 8.html new file mode 100644 index 0000000..238ee00 --- /dev/null +++ b/Javascript/Session 2/example 8.html @@ -0,0 +1,29 @@ + + + + + My Page + + + +

Big Title

+
+ google photo +

Lorem ipsum dolor sit amet consectetur adipisicing elit. Impedit, voluptate cumque? Mollitia fuga non voluptate officia possimus necessitatibus, voluptatibus minus dolor soluta sunt unde, omnis aliquam vel dolores. Iusto, autem!

+
+ + + + + \ No newline at end of file diff --git a/Javascript/Session 2/example 9.html b/Javascript/Session 2/example 9.html new file mode 100644 index 0000000..90ec310 --- /dev/null +++ b/Javascript/Session 2/example 9.html @@ -0,0 +1,34 @@ + + + + + My Page + + + +

Big Title

+
+ google photo +

Lorem ipsum dolor sit amet consectetur adipisicing elit. Impedit, voluptate cumque? Mollitia fuga non voluptate officia possimus necessitatibus, voluptatibus minus dolor soluta sunt unde, omnis aliquam vel dolores. Iusto, autem!

+ + + + +
+ + + + + \ No newline at end of file diff --git a/Javascript/Session 3/AJAX.html b/Javascript/Session 3/AJAX.html new file mode 100644 index 0000000..f902752 --- /dev/null +++ b/Javascript/Session 3/AJAX.html @@ -0,0 +1,28 @@ + + + + + + Document + + + + diff --git a/Javascript/Session 3/Fetch.html b/Javascript/Session 3/Fetch.html new file mode 100644 index 0000000..f400e42 --- /dev/null +++ b/Javascript/Session 3/Fetch.html @@ -0,0 +1,14 @@ + + + + + + Document + + + + diff --git a/Javascript/Session 3/JavaScript_Session-3.pdf b/Javascript/Session 3/JavaScript_Session-3.pdf new file mode 100644 index 0000000..674c71e Binary files /dev/null and b/Javascript/Session 3/JavaScript_Session-3.pdf differ diff --git a/Javascript/Session 3/example 1.html b/Javascript/Session 3/example 1.html new file mode 100644 index 0000000..d0839b0 --- /dev/null +++ b/Javascript/Session 3/example 1.html @@ -0,0 +1,26 @@ + + + + + My Page + + + +

Big Title

+ + + + + + + \ No newline at end of file diff --git a/Javascript/Session 3/example 2.html b/Javascript/Session 3/example 2.html new file mode 100644 index 0000000..9f69f53 --- /dev/null +++ b/Javascript/Session 3/example 2.html @@ -0,0 +1,23 @@ + + + + + My Page + + + +

Big Title

+ + + + + + + \ No newline at end of file diff --git a/Javascript/Session 3/example 3.html b/Javascript/Session 3/example 3.html new file mode 100644 index 0000000..dff2038 --- /dev/null +++ b/Javascript/Session 3/example 3.html @@ -0,0 +1,36 @@ + + + + + My Page + + + +

Big Title

+ + + + + + + \ No newline at end of file diff --git a/Javascript/Session 3/example 4.html b/Javascript/Session 3/example 4.html new file mode 100644 index 0000000..416c20b --- /dev/null +++ b/Javascript/Session 3/example 4.html @@ -0,0 +1,39 @@ + + + + + My Page + + + +

Big Title

+ + + + + + + \ No newline at end of file diff --git a/Javascript/Session 3/promises.js b/Javascript/Session 3/promises.js new file mode 100644 index 0000000..9443be3 --- /dev/null +++ b/Javascript/Session 3/promises.js @@ -0,0 +1,13 @@ +var x = 10; +var myPromise = new Promise(function (resolve, reject) { + if (x == 10) resolve("success"); + else reject("fail"); +}); + +myPromise + .then((res) => { + console.log(res); + return res; + }) + .then((res) => console.log(res + " Done")) + .catch((err) => console.log(err)); diff --git a/README.md b/README.md index cdc575a..8735128 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,20 @@ # Full-Stack -## Agenda +## Agenda 📑 -- [What You Need To Learn These Technologies?](https://github.com/nadamedhat27/Full-Stack#what-you-need-to-learn-these-technologies) +- [Table of Contents](https://github.com/nadamedhat27/Full-Stack#table-of-contents) 🔖 +- [What You Need To Learn These Technologies?](https://github.com/nadamedhat27/Full-Stack#what-you-need-to-learn-these-technologies) 💡 - [How to contribute 🤝](https://github.com/nadamedhat27/Full-Stack#how-to-contribute-) ---------------------------------------------------------------- +- ## Table of Contents + + ### JavaScript + | Sessions | Description | + |------|------| + | [Session 1](./Javascript/Session%201/) | | + | [Session 2](./Javascript/Session%202/) | | + - ## What You Need To Learn These Technologies?