-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
98 lines (86 loc) · 2.09 KB
/
app.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
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
const express = require('express')
const bodyParser = require('body-parser')
const models = require('./models')
const app = express()
app.set('view engine', 'ejs')
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json())
app.get('/', (req, res) => {
res.render('index')
})
// ========== TEACHER PAGE ==========
const teachers = require('./routers/teacher')
app.use('/teachers', teachers)
// ========== SUBJECT PAGE ==========
const subject = require('./routers/subject')
app.use('/subject', subject)
// ========== STUDENTS PAGE ==========
const student = require('./routers/student')
app.use('/student', student)
// app.get('/student', (req, res) => {
// models.Student.findAll()
// .then(students => {
// res.render('student', {data: students, title: 'Student Page'})
// })
// .catch(err => {
// res.send(err)
// })
// })
//
// app.post('/student', (req, res) => {
// models.Student.build({
// first_name: `${req.body.fn}`,
// last_name: `${req.body.ln}`,
// email: `${req.body.email}`,
// createdAt: new Date()
// })
// .save().then(students => {
// res.redirect('/student')
// })
// })
//
// app.get('/student/edit/:id', (req, res) => {
// models.Student.findAll({
// where: {
// id: req.params.id
// }
// })
// .then(students => {
// res.render('studentEdit', {data: students[0], title: 'Edit Student Page'})
// })
// })
//
// app.post('/student/edit/:id', (req, res) => {
// models.Student.update({
// first_name: `${req.body.fn}`,
// last_name: `${req.body.ln}`,
// email: `${req.body.email}`,
// updatedAt: new Date()
// },
// {
// where: {
// id: req.params.id
// }
// })
// .then(students => {
// res.redirect('/student')
// })
// })
//
// app.get('/student/delete/:id', (req, res) => {
// models.Student.destroy({
// where: {
// id: req.params.id
// }
// })
// .then(students => {
// res.redirect('/student')
// })
// .catch(err => {
// res.send(err)
// })
// })
//
app.listen(3000,() => {
console.log('AYO JALAN!');
})