forked from git-Suyash/Hack-o-mania-Alt-F4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
47 lines (38 loc) · 1.35 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
import express from "express";
import bodyParser from "body-parser";
import dbSetup from './database.js';
import generateUserId from "./registerUser.js";
const app = express();
const port = 3000;
app.use(express.static('public'));
app.use(bodyParser.urlencoded({ extended: true }));
// Connect to the database before anything else
app.get("/", (req, res) => { //homepage , landing
res.sendFile(process.cwd() + "/public/index.html");
});
app.get("/log-in", (req, res) => {
res.sendFile(process.cwd() + "/public/login.html");
});
app.post("/login",(req,res)=>{ // check from db and validate
console.log(req.body);
// add functionality here
//app.use(dbSetup);
res.sendFile(process.cwd()+"/public/dashb_farmer.html");
});
app.get('/adloginpage',(req,res)=>{
res.sendFile(process.cwd()+"/public/adminlogin.html");
});
app.post("/register", (req,res) => {
app.use(bodyParser.urlencoded({ extended: true }));
console.log(req.body);
app.use(generateUserId); // middleware to create user id
res.redirect('/log-in');
console.log("registered");
});
app.get('/admin-login', (req,res)=>{
res.sendFile(process.cwd()+"/public/dashboard.html");
});
app.post("/upload", (req,res) => { // update to db
console.log("file upload");
});
app.listen(port, () => console.log(`Server running on http://localhost:${port}/`));