-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
157 lines (125 loc) · 4.45 KB
/
index.js
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
const express = require("express");
const bodyParser = require("body-parser");
const path = require("path");
const { Sequelize, DataTypes } = require("sequelize");
const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(express.static(path.join(__dirname, "public")));
// SQLite setup
const sequelize = new Sequelize({
dialect: "sqlite",
storage: path.join(__dirname, "database.sqlite"), // Change the database file path
});
// Define the User model
const User = sequelize.define("User", {
first_name: DataTypes.STRING,
last_name: DataTypes.STRING,
email: DataTypes.STRING,
phone: DataTypes.STRING,
password: DataTypes.STRING,
});
// Sync the model with the database
sequelize.sync();
app.set("port", process.env.PORT || 5000);
// Home page
app.get("/", (req, res) => {
res.sendFile(path.join(__dirname, "public", "index.html"));
});
// Booking Form page
app.get("/BookingForm", (req, res) => {
res.sendFile(path.join(__dirname, "public", "booking.html"));
});
app.post("/BookingForm", async (req, res) => {
const { name, address, email, contact_no, indate, outdate } = req.body;
try {
// Assuming you have a User model or a table in your database
const user = await db.query(
"INSERT INTO users (Full Name, email,Check indate, Check outdate) VALUES (?, ?, ?, ?, ?, ?)",
["FullName, email,Check indate, Check outdate"]
);
// You can also perform additional actions here if needed
res.redirect("/");
} catch (error) {
console.error(error);
res.status(500).send("Booking failed. Please try again.");
}
});
// Deluxe Booking Form page
app.get("/deluxeRoom", (req, res) => {
res.sendFile(path.join(__dirname, "public", "deluxe.html"));
});
app.post("/deluxeRoom", async (req, res) => {
const { name, address, email, contact_no, indate, outdate } = req.body;
try {
// Assuming you have a User model or a table in your database
const user = await db.query(
"INSERT INTO users (Full Name, email,Check indate, Check outdate) VALUES (?, ?, ?, ?, ?, ?)",
["FullName, email,Check indate, Check outdate"]
);
// You can also perform additional actions here if needed
res.redirect("/");
} catch (error) {
console.error(error);
res.status(500).send("Booking failed. Please try again.");
}
});
// family Booking Form page
app.get("/FamilyRoom", (req, res) => {
res.sendFile(path.join(__dirname, "public", "family.html"));
});
app.post("/FamilyRoom", async (req, res) => {
const { name, address, email, contact_no, indate, outdate } = req.body;
try {
// Assuming you have a User model or a table in your database
const user = await db.query(
"INSERT INTO users (Full Name, email,Check indate, Check outdate) VALUES (?, ?, ?, ?, ?, ?)",
["FullName, email,Check indate, Check outdate"]
);
// You can also perform additional actions here if needed
res.redirect("/");
} catch (error) {
console.error(error);
res.status(500).send("Booking failed. Please try again.");
}
});
// Luxury Booking Form page
app.get("/LuxuryRoom", (req, res) => {
res.sendFile(path.join(__dirname, "public", "Luxury.html"));
});
app.post("/FamilyRoom", async (req, res) => {
const { name, address, email, contact_no, indate, outdate } = req.body;
try {
// Assuming you have a User model or a table in your database
const user = await db.query(
"INSERT INTO users (Full Name, email,Check indate, Check outdate) VALUES (?, ?, ?, ?, ?, ?)",
["FullName, email,Check indate, Check outdate"]
);
// You can also perform additional actions here if needed
res.redirect("/");
} catch (error) {
console.error(error);
res.status(500).send("Booking failed. Please try again.");
}
});
app.get("/privacy&policy", (req, res) => {
res.sendFile(path.join(__dirname, "public", "privacy.html"));
});
app.get("/terms&condition", (req, res) => {
res.sendFile(path.join(__dirname, "public", "terms.html"));
});
app.get("/faq", (req, res) => {
res.sendFile(path.join(__dirname, "public", "faq.html"));
});
app.get("/cancelation", (req, res) => {
res.sendFile(path.join(__dirname, "public", "cancel.html"));
});
app.get("/Rooms", (req, res) => {
res.sendFile(path.join(__dirname, "public", "rooms.html"));
});
app.get("/chat", (req, res) => {
res.sendFile(path.join(__dirname, "public", "chat.html"));
});
app.listen(app.get("port"), function () {
console.log("Node app is running at localhost:" + app.get("port"));
});