-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
44 lines (31 loc) · 975 Bytes
/
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
const express=require('express');
const create = require('./contorllers/create');
const read = require('./contorllers/read');
const url = require('url');
const update = require('./contorllers/update');
const _delete= require('./contorllers/delete');
const app= express();
app.set('view engine','ejs')
app.set('views', './views');
app.use(express.static('./views'));
// app.use(express.json());
// app.use(express.urlencoded({ extended: true }));
app.get('/',function(req,res){
// res.render('crud-form');
read.read_data(req,res);
})
app.post('/create',function(req,res){
create.create_data(req,res);
})
app.get('/update',function(req,res){
var req_url = req.url;
var query_data = url.parse(req_url, true).query;
res.render('update-form', {id : query_data.id});
})
app.post('/update_process',function(req,res){
update.update_data(req,res);
})
app.post('/delete',function(req,res){
_delete.delete_data(req,res);
})
app.listen(3000);