-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
56 lines (45 loc) · 1.02 KB
/
server.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
const express = require("express");
const bodyParser= require("body-parser");
const app= express();
var newadd;
var items=[];
var work=[];
app.use(bodyParser.urlencoded({extended: true}));
app.set('view engine','ejs');
app.use(express.static("views"));
app.get("/",function(req,res){
var today= new Date();
var options={
weekday: "long",
day : "numeric",
month: "long"
};
var day =today.toLocaleDateString("en-US",options);
res.render("list",{
title:day,
newiteminlist:items
});
})
app.post("/",function(req,res){
newadd= req.body.addtext;
//console.log(req.body.button);
if(req.body.button === "Work")
{
work.push(newadd);
res.redirect("/work");
}
else
{
items.push(newadd);
res.redirect("/");
}
})
app.get("/work",function(req,res){
res.render("list",{
title:"Work",
newiteminlist:work
})
})
app.listen(3000,function(){
console.log("Server is running on 3000!!!");
})