-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9796f79
commit dc75478
Showing
26 changed files
with
308 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
html | ||
head | ||
title Demo | ||
body | ||
h1 Pug File | ||
table | ||
tr | ||
td 1 | ||
td rahul | ||
td 78 | ||
tr | ||
td 2 | ||
td ajay | ||
td 79 | ||
tr | ||
td=ename | ||
td=salary | ||
td=mobile | ||
|
||
h1 #{ename} | ||
table | ||
tr | ||
td=exp[0] | ||
td=exp[1] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Day 6 (Adding Static Files) | ||
|
||
const express = require("express"); | ||
const app = express(); | ||
|
||
app.set("view engine", "pug"); | ||
app.set("views", "./view"); | ||
|
||
app.use(express.static('public')); | ||
|
||
app.get("/",function(request,response){ | ||
response.render("demo2"); | ||
}); | ||
|
||
app.listen(5000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
h1{ | ||
color: red; | ||
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
html | ||
head | ||
title Static File | ||
link(href="/css/style.css" rel="stylesheet") | ||
body | ||
h1 This Demo File. | ||
img(src="/images/bg2.jpg") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Day 7 (Retrive Data from Form using POST and GET Method) | ||
|
||
const express = require("express"); | ||
const app = express(); | ||
// use body parse for get data by post method | ||
const bodyParser = require("body-parser"); | ||
app.set("view engine", "pug"); | ||
app.set("views", "./view"); | ||
app.use(bodyParser.json()); // for post method bcs post me data direct json k formet m hota h | ||
// for get/post method use urlencoded to encode data that we get from url | ||
app.use(bodyParser.urlencoded({extended:true})); | ||
app.get("/", function (request, response) { | ||
response.render("Lec8"); // not retrive | ||
}); | ||
|
||
app.get("/submit",function(request,response){ | ||
// response.send(request.query); // to get GET METHOD data use request.query | ||
// response.send(JSON.stringify(request.query)); // to convert get data in string | ||
console.log(request.query.roll); | ||
var student = JSON.parse(JSON.stringify(request.query)); | ||
response.render("Lec8",{stud:student}); | ||
}); | ||
app.post("/submit", function (request, response) { | ||
// response.send("Record not found"); | ||
response.send(request.body); // post m data json object hi hota h | ||
console.log(request.body); | ||
console.log(request.body.roll+" "+request.body.sname+" "+request.body.avg); | ||
}); | ||
|
||
app.listen(5000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
doctype html | ||
head | ||
title Bootstrap Example | ||
meta(charset='utf-8') | ||
meta(name='viewport' content='width=device-width, initial-scale=1') | ||
link(rel='stylesheet' href='https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css') | ||
script(src='https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js') | ||
script(src='https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js') | ||
script(src='https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js') | ||
style | ||
include ./style.css | ||
.container | ||
.row | ||
.col-sm-3 | ||
.col-sm-6 | ||
//- form(method='post' action='/submit') | ||
label.form-label Roll No. | ||
br | ||
input.form-control(type='text' name='roll') | ||
br | ||
label.form-label Name | ||
br | ||
input.form-control(type='text' name='sname') | ||
br | ||
label.form-label Avg | ||
br | ||
input.form-control(type='text' name='avg') | ||
br | ||
input.btn.btn-danger(type='submit' name='submit' value='submit') | ||
br | ||
if(stud) | ||
h3 #{stud.roll} | ||
h3 #{stud.sname} | ||
h3 #{stud.avg} | ||
form(method='post' action='/submit') | ||
label.form-label Roll No. | ||
br | ||
input.form-control(type='text' name='sn') | ||
br | ||
label.form-label Name | ||
br | ||
input.form-control(type='text' name='sname') | ||
br | ||
label.form-label Avg | ||
br | ||
input.form-control(type='text' name='avg') | ||
br | ||
label.form-label Gender | ||
br | ||
input(type='radio' value='Male') | ||
| Male | ||
input(type='radio' value='Female') | ||
| Female | ||
br | ||
input.btn.btn-danger(type='submit' name='submit' value='submit') | ||
br | ||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Day 8 (Database Connectivity) | ||
const express = require("express"); | ||
const mysql = require("mysql"); | ||
const app = express(); | ||
const bodyParser = require("body-parser"); | ||
const {UCS2_GENERAL_MYSQL500_CI,} = require("mysql/lib/protocol/constants/charsets"); | ||
app.set("view engine", "pug"); | ||
app.set("views", "./view"); | ||
|
||
app.use(bodyParser.json()); | ||
app.use(bodyParser.urlencoded({ extended: true })); | ||
app.get("/", function (request, response) { | ||
response.render("Lec9"); | ||
}); | ||
app.post("/submit", function (request, response) { | ||
var conn = mysql.createConnection({ | ||
host: "localhost", | ||
user: "root", | ||
password: "", | ||
database: "cet", | ||
}); | ||
conn.connect(function (err) { | ||
if (err) throw err; | ||
conn.query( | ||
"insert into student values("+request.body.roll+",'"+request.body.sname+"',"+request.body.avg+")",function (err, result) { | ||
if (err) console.log("Try Again"); | ||
else { | ||
// console.log("Record Inserted"); | ||
response.redirect("/record"); | ||
} | ||
} | ||
); | ||
}); | ||
conn.end; | ||
}); | ||
|
||
app.listen(5000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
doctype html | ||
head | ||
title Bootstrap Example | ||
meta(charset='utf-8') | ||
meta(name='viewport' content='width=device-width, initial-scale=1') | ||
link(rel='stylesheet' href='https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css') | ||
script(src='https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js') | ||
script(src='https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js') | ||
script(src='https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js') | ||
style | ||
include ./style.css | ||
.container | ||
.row | ||
.col-sm-3 | ||
.col-sm-6 | ||
form(method='post' action='/submit') | ||
label.form-label Roll No. | ||
br | ||
input.form-control(type='text' name='roll') | ||
br | ||
label.form-label Name | ||
br | ||
input.form-control(type='text' name='sname') | ||
br | ||
label.form-label Avg | ||
br | ||
input.form-control(type='text' name='avg') | ||
br | ||
input.btn.btn-danger(type='submit' name='submit' value='submit') | ||
br | ||
if(stud) | ||
h3 #{stud.roll} | ||
h3 #{stud.sname} | ||
h3 #{stud.avg} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
p{ | ||
font-size: medium; | ||
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Day 9 (Data Display after passing to pug file) | ||
const express = require("express"); | ||
const mysql = require("mysql"); | ||
const app = express(); | ||
const bodyParser = require("body-parser"); | ||
const {UCS2_GENERAL_MYSQL500_CI,} = require("mysql/lib/protocol/constants/charsets"); | ||
app.set("view engine", "pug"); | ||
app.set("views", "./view"); | ||
|
||
app.use(bodyParser.json()); | ||
app.use(bodyParser.urlencoded({ extended: true })); | ||
app.get("/", function (request, response) { | ||
response.render("Lec9"); | ||
}); | ||
app.post("/submit", function (request, response) { | ||
var conn = mysql.createConnection({ | ||
host: "localhost", | ||
user: "root", | ||
password: "", | ||
database: "cet", | ||
}); | ||
conn.connect(function (err) { | ||
if (err) throw err; | ||
conn.query( | ||
"insert into student values("+request.body.roll+",'"+request.body.sname+"',"+request.body.avg+")",function (err, result) { | ||
if (err) console.log("Try Again"); | ||
else { | ||
// console.log("Record Inserted"); | ||
response.redirect("/record"); | ||
} | ||
} | ||
); | ||
}); | ||
conn.end; | ||
}); | ||
app.get("/record", function (request, response) { | ||
var conn = mysql.createConnection({ | ||
host: "localhost", | ||
user: "root", | ||
password: "", | ||
database: "cet", | ||
}); | ||
conn.connect(function (err) { | ||
if (err) throw err; | ||
conn.query("select * from student", function (err, result) { | ||
if (err) console.log("Try Again"); | ||
else { | ||
response.render("Day9", { stud: result }); | ||
} | ||
}); | ||
}); | ||
conn.end; | ||
}); | ||
|
||
|
||
app.listen(5000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
doctype html | ||
head | ||
title Bootstrap Example | ||
meta(charset='utf-8') | ||
meta(name='viewport' content='width=device-width, initial-scale=1') | ||
link(rel='stylesheet' href='https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css') | ||
script(src='https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js') | ||
script(src='https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js') | ||
script(src='https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js') | ||
style | ||
include ./style.css | ||
.container | ||
.row | ||
.col-sm-3 | ||
.col-sm-6 | ||
form(method='post' action='/submit') | ||
label.form-label Roll No. | ||
br | ||
input.form-control(type='text' name='roll') | ||
br | ||
label.form-label Name | ||
br | ||
input.form-control(type='text' name='sname') | ||
br | ||
label.form-label Avg | ||
br | ||
input.form-control(type='text' name='avg') | ||
br | ||
input.btn.btn-danger(type='submit' name='submit' value='submit') | ||
br | ||
if(stud) | ||
h3 #{stud.roll} | ||
h3 #{stud.sname} | ||
h3 #{stud.avg} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
p{ | ||
font-size: medium; | ||
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; | ||
} |