-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
41 lines (31 loc) · 884 Bytes
/
app.js
File metadata and controls
41 lines (31 loc) · 884 Bytes
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
const express = require("express");
const date = require(__dirname+ "/date.js");
const mongoose = require("mongoose");
const app = express();
var items = ['Buy food','Cook food','Eat food'];
var workItems = [];
app.use(express.urlencoded({extended: true}));
app.use(express.static("public"))
app.set('view engine', 'ejs');
app.get('/', function(req,res){
let day = date();
res.render('list', {ListTitle: day, NewListitem: items});
})
app.get('/work', function(req,res){
res.render('list', {ListTitle: "Work list", NewListitem: workItems});
})
app.get('/about', function(req,res){
res.render('about');
})
app.post('/', function(req,res){
if(req.body.list == "Work"){
workItems.push(req.body.userinput);
res.redirect('/work');
}else{
items.push(req.body.userinput);
res.redirect('/');
}
})
app.listen(3000,function(){
console.log("Server up!");
})