-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
44 lines (36 loc) · 1.02 KB
/
app.js
File metadata and controls
44 lines (36 loc) · 1.02 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
const express = require("express");
const path = require("path");
const app = express();
const PORT = 3016;
// Middleware
app.use(express.urlencoded({ extended: true }));
app.use(express.static("public"));
// Views
app.get("/", (req, res) => {
res.sendFile(path.join(__dirname, "views", "login.html"));
});
// Login
app.post("/login", (req, res) => {
const { username, password } = req.body;
if (username === "admin" && password === "admin123") {
res.sendFile(path.join(__dirname, "views", "dashboard.html"));
} else {
res.send("<h3>❌ Invalid credentials</h3><a href='/'>Try again</a>");
}
});
// Payment page
app.get("/payment", (req, res) => {
res.sendFile(path.join(__dirname, "views", "payment.html"));
});
// Payment processing (mock)
app.post("/pay", (req, res) => {
const { amount } = req.body;
res.send(`
<h2>✅ Payment Successful</h2>
<p>Amount Paid: ₹${amount}</p>
<a href="/payment">Back</a>
`);
});
app.listen(PORT, () => {
console.log(`🚀 Server running on port ${PORT}`);
});