-
Notifications
You must be signed in to change notification settings - Fork 0
/
app1.js
71 lines (58 loc) · 1.27 KB
/
app1.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
const express = require('express');
const bodyParser = require('body-parser');
const app= express();
var items=["get exsersize","eat well","practice well"];
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({extended: true}));
app.use(express.static("public"));
app.get("/", function (req,res) {
var today =new Date();
// var currentDay =today.getDay();
// var day="";
//
// switch (currentDay) {
// case 0:
// day = "sunday";
// break;
// case 1:
// day = "monday";
// break;
// case 2:
// day = "tuesday";
// break;
// case 3:
// day = "wednesday";
// break;
// case 4:
// day = "thursday";
// break;
// case 5:
// day = "friday";
// break;
// case 6:
// day = "saturday";
// break;
//
//
// default:
// console.log("Error: current day is" + currentDay);
// }
var options={
day:"numeric",
weekday: "long",
year: "numeric",
month: "long"
}
const day=today.toLocaleDateString("ta",options);
res.render("list1",{
kindOfDay: day, newListItems: items});
});
app.post("/", function (req,res) {
const item=req.body.newItem;
items.push(item);
res.redirect("/");
console.log(item);
})
app.listen(3000, function () {
console.log("server is working on port 3000");
});