forked from 02Ravi/Hack36_Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
136 lines (104 loc) · 3.09 KB
/
app.js
File metadata and controls
136 lines (104 loc) · 3.09 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
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
const express = require("express");
const app = express();
const fs = require("fs");
const path = require('path');
//MONGOOSE
// const mongoose = require('mongoose');
// const { Collection } = require("mongodb");
// mongoose.connect("mongodb://localhost/webDB",
// process.env.MONGO_URL,
// {
// useNewUrlParser: true,
// useUnifiedTopology: true,
// useCreateIndex: true,
// },
// () => {
// console.log("mongdb is connected");
// }
// );
// let db = mongoose.connection;
// db.on("error", console.error.bind(console, "connection error"));
// db.once("open", () => {
// console.log("connected");
// });
// const loginSchema = new mongoose.Schema({
// phoneNo: String,
// password: String
// });
// const loginModel = mongoose.model('users', loginSchema);
// const silence = new loginModel({ phoneNo: '92', password: "ak" });
// silence.save(function (err, result) {
// if (err) {
// console.log(err);
// }
// // else {
// // console.log(result)
// // }
// });
//STATIC FILES
// app.use(express.static(path.join(__dirname, "/index.css"))); //delete
app.use(express.static(path.join(__dirname, "Seller/cssANDjs")));
app.use(express.static(path.join(__dirname, "Consumer/cssANDjs")));
app.use(express.static(path.join(__dirname, "Seller/images")));
app.use(express.static(path.join(__dirname, "Consumer/images")));
//MIDDLEWARES
app.use(express.json());
app.use(express.urlencoded());
//HOMEPAGE
const index = fs.readFileSync("index.html", "utf-8");
//SELLER
const merchant = fs.readFileSync("Seller/indexS.html", "utf-8");
const signin_page = fs.readFileSync("Seller/signinS.html", "utf-8");
const signup_page = fs.readFileSync("Seller/signupS.html", "utf-8");
const display_Prod = fs.readFileSync("Seller/disProd.html", "utf-8");
const addItems_page = fs.readFileSync("Seller/add.html", "utf-8");
//CONSUMER
const customer = fs.readFileSync("Consumer/indexC.html", "utf-8");
//HOME NAVIGATION
app.get("/", (req, res) => {
res.send(index);
});
app.get("/about", (req, res) => {
res.status(300).send(index);
});
app.get("/contact", (req, res) => {
res.status(300).send(index);
});
//SELLER NAVIGATION
app.get("/seller", (req, res) => {
res.send(merchant);
});
app.get("/seller/signin", (req, res) => {
res.send(signin_page);
});
app.get("/seller/signup", (req, res) => {
res.send(signup_page);
});
//CONSUMER NAVIGATION
app.get("/consumer", (req, res) => {
res.send(customer);
});
//SIGNIN DATABASE
app.get("/disProd", (req, res) => {
// const silence = new loginModel(req.body);
// console.log(req.body);
// silence.save(function (err, result) {
// if (err) {
// console.log(err);
// }
// res.json(silence);
// });
res.send(display_Prod);
});
app.post("/disProd", (req, res) => {
res.send(display_Prod);
});
app.get("/addItem", (req, res) => {
res.send(addItems_page);
});
//STARTING SERVER
const hostname = '127.0.0.1';
const port = 80;
app.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});