Node.Js Tutorial For Beginners 21 - Express.Js Road Parameter



var limited = require('express'); var app = express();  app.get('/', function(req, rep) {     rep.send('this is abode page'); })  app.get('/about', function(req, rep) {     rep.send('this is close page'); })  app.get('/contect', function(req, rep) {     rep.send('this is contect page'); })  var students = {     1 : 'Mark',     2 : 'Tom',     3 : 'john' }  app.get('/students/:id', function(req, rep) {     rep.send('you accept requested to run into the pupil mention : '+ students[req.params.id]); })  app.listen(3000, function() {     console.log('our server is alive on posrt 3000'); }) 

Linux Ascendency Business Tutorial | Larn In Conclusion Commands

Node.Js Tutorial For Beginners 22 - Node.Js Template Engine Ejs Inwards Express





Project files

about.html index.html index.js   node_modules/   package.json   views/students.ejs 


index.js
var limited = require('express'); var app = express();  app.set('view engine', 'ejs');  app.get('/', function(req, rep) {     rep.sendFile(__dirname + '/index.html'); })  app.get('/about', function(req, rep) {     rep.sendFile(__dirname + '/about.html'); })  var students = {     1 : 'Mark',     2 : 'Tom',     3 : 'john' }  app.get('/students/:id', function(req, rep) {     rep.render('students', { advert : students[req.params.id] , id : req.params.id}); })  app.listen(3000, function() {     console.log('our server is alive on posrt 3000'); }) 

package.json
{   "name": "express_test",   "version": "1.0.0",   "description": "",   "main": "index.js",   "scripts": {     "test": "echo \"Error: no exam specified\" && give-up the ghost 1"   },   "author": "",   "license": "ISC",   "dependencies": {     "ejs": "^2.5.5",     "express": "^4.14.1"   } } 

\views\students.ejs
<html>     <head>         <style>             body {                 background-color: limegreen             }         </style>     </head>     <body>         <h1>You convey requested the pupil advert : <%= advert %></h1>         <p>id : <%= id %></p>     </body> </html> 

index.html
<html>     <head>         <style>             body {                 background-color: limegreen             }         </style>     </head>     <body>         <h1>Home Page</h1>     </body> </html> 


about.html


<html>     <head>         <style>             body {                 background-color: limegreen             }         </style>     </head>     <body>         <h1>About Page</h1>     </body> </html> 

Node.Js Tutorial For Beginners 23 - Using Javascript Amongst Ejs



Project files

index.js   node_modules/   package.json   views/views/students.ejs 



index.js



var limited = require('express'); var app = express();  app.set('view engine', 'ejs');  var students = {     1 : {         cite : 'Mark',         subjects : ['c++', 'Java', 'c']     },     2 : {         cite : 'Tom',         subjects : ['C#', 'Pthon', 'Mysql']     },     3 : {         cite : 'John',         subjects : ['Javascript', 'Sqlite', 'c']     }, }  app.get('/students/:id', function(req, rep) {     rep.render('students', { cite : students[req.params.id].name , id : req.params.id         , subjects : students[req.params.id].subjects}); })  app.listen(3000, function() {     console.log('our server is alive on posrt 3000'); }) 

package.json

{   "name": "express_test",   "version": "1.0.0",   "description": "",   "main": "index.js",   "scripts": {     "test": "echo \"Error: no examination specified\" && conk 1"   },   "author": "",   "license": "ISC",   "dependencies": {     "ejs": "^2.5.5",     "express": "^4.14.1"   } } 

\views\students.ejs

<html>     <head>         <style>             body {                 background-color: limegreen             }         </style>     </head>     <body>         <h1>You convey requested the pupil cite : <%= cite %></h1>         <p>id : <%= id %></p>         <h1>Subjects</h1>         <ul>          <% subjects.forEach(function(item) { %>            <li> <%= special %></li>          <%});%>         </ul>     </body> </html> 

Shell Scripting Tutorial For Beginners I - Using Variables Too Comments



#! /bin/bash # this is a comment echo "Hello World" # this is as well as a comment  echo Our vanquish cite is $BASH echo Our vanquish version cite is $BASH_VERSION echo Our habitation directory is $HOME echo Our electrical flow working directory is $PWD  name=Mark VALUE=10 echo The cite is $name echo value $VALUE 

Shell Scripting Tutorial For Beginners Four - Snuff It Arguments To A Bash-Script





#! /bin/bash  # $* Returns a unmarried string (``$1, $2 ... $n'')  # comprising all of the positional parameters # separated past times the internal plain separator graphic symbol  #(defined past times the IFS surroundings variable). # $0 Refers to the refer of the script itself echo $0 $1 $2 $3  ' > echo $1 $2 $3'  # $@ Returns a sequence of strings  # (``$1'', ``$2'', ... ``$n'') # wherein each positional parameter  # remains variety from the others. args=("$@")  echo ${args[0]} ${args[1]} ${args[2]}   echo $@  # $# Refers to the lay out of arguments  # specified on a ascendence line. echo $# 
output:


test@test$ ./hello.sh Mark Tom John ./hello.sh Mark Tom John  > echo $1 $2 $3 Mark Tom John Mark Tom John 3 

Shell Scripting Tutorial For Beginners Five - If Arguing ( If In Addition To Thus , If T...





Bash Shell

Conditional Statements 
  • Conditionals let us elevate one's hear whether to perform an activity or not, this determination is taken yesteryear evaluating an expression. The almost basic assort is:


      if [ aspect ];

      then

            statements

      elif [ aspect ];

      then

            statements

      else

            statements

      fi

  • the elif (else if) and else sections are optional
  • Put spaces later [ and before ], and around the operators and operands. 
Bash Shell

Expressions 
  • An expression can be: String comparisonNumeric comparisonFile operators and Logical operators and it is represented by [expression]:
  • String Comparisons: 


=  compare if 2 strings are equal

!=  compare if 2 strings are not equal

-n  evaluate if string length is greater than zero

-z  evaluate if string length is equal to zero

  • Examples:


[ s1 = s2 ]  (true if s1 same equally s2, else false)

[ s1 != s2 ]  (true if s1 non same equally s2, else false)

[ s1 ]   (true if s1 is non empty, else false)

[ -n s1 ]   (true if s1 has a length greater too thus 0, else false)

[ -z s2 ]   (true if s2 has a length of 0, otherwise false)

Bash Shell

Expressions 
  • Number Comparisons:


-eq compare if 2 numbers are equal

-ge         compare if i pose out is greater than or equal to a number

-le  compare if i pose out is less than or equal to a number

-ne  compare if 2 numbers are not equal

-gt  compare if i pose out is greater than roughly other number

-lt  compare if i pose out is less than roughly other number

  • Examples:


[ n1 -eq n2 ]  (true if n1 same equally n2, else false)

[ n1 -ge n2 ]  (true if n1greater too thus or equal to n2, else false)

[ n1 -le n2 ]  (true if n1 less too thus or equal to n2, else false)

[ n1 -ne n2 ]  (true if n1 is non same equally n2, else false)

[ n1 -gt n2 ]  (true if n1 greater too thus n2, else false)

[ n1 -lt n2 ]  (true if n1 less too thus n2, else false)

Bash Shell

Examples 
cat user.sh

 #!/bin/bash

      echo -n “Enter your login name: "

      read name

      if [ “$name” = “$USER” ];

      then

            echo “Hello, $name. How are y'all today ?”

      else

            echo “You are non $USER, thus who are y'all ?”

      fi

cat number.sh

#!/bin/bash

      echo -n “Enter a pose out 1 < x < 10: "

      read num

      if [ “$num” -lt ten ]; then

            if [ “$num” -gt 1 ]; then

                  echo “$num*$num=$(($num*$num))”

            else

                  echo “Wrong insertion !”

            fi

      else

            echo “Wrong insertion !”

      fi





#! /bin/bash  word=a  if  [[ $word == "b" ]] then   echo "condition b is true" elif [[ $word == "a" ]] then    echo "condition a is true"  else   echo "condition is false"     fi 

Search

Blog Archive