-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
72 lines (63 loc) · 1.57 KB
/
app.js
File metadata and controls
72 lines (63 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const express = require("express");
const exphbs = require("express-handlebars");
const bodyParser = require("body-parser");
const path = require("path");
const mongoose = require("mongoose");
const app = express();
const keys = require("./config/keys");
require("./models/New");
const New = mongoose.model("newdata");
//bodyparser middleware
app.use(bodyParser.urlencoded({ extended:false}));
app.use(bodyParser.json());
//handlebars middleware
app.engine("handlebars", exphbs({ defaultLayout: "main" }));
app.set("view engine", "handlebars");
//for public folder
app.use(express.static(path.join(__dirname, "public")));
mongoose
.connect(keys.mongoURI)
.then(() => {
console.log("database is connected");
})
.catch(err => {
console.log("database is down");
});
//@desc first index page
app.get("/", (req, res) => {
res.render("index");
});
//@desc ifsc code input page
app.get("/ifsc", (req, res) => {
res.render("ifsc");
});
//@desc ifsc code search
app.post("/ifsc", (req, res) => {
New.findOne({ ifsc: req.body.password }).then(data => {
res.render("ill", {
rows: data
});
});
});
//@desc name and city input page
app.get("/namecity", (req, res) => {
res.render("namecity");
});
//@desc name and city search
app.post("/bncity", (req, res) => {
New.find({
bank_name: req.body.name,
city: req.body.city
}).then(data => {
res.render("akk", {
rows: data
});
});
});
//@desc about page
app.get("/about", (req, res) => {
res.render("about");
});
app.listen(process.env.PORT || 3000, () => {
console.log("server is running");
});