-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
92 lines (75 loc) · 2.42 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
// MYSQL
// const mysql = require('mysql');
const connection = require('./db/mysqlConenction'); //export mysql connection
// Express
const express = require('express');
const app = express()
const port = 3000
const hostname = "localhost"
// Body Parser
const bodyParser = require('body-parser');
app.set("view engine", "ejs")
app.use(express.static('images'));
// Bodyparser middleware
app.use(bodyParser.urlencoded({extended: false}))
app.use(bodyParser.json())
// Routing
app.get("/", (req, res) => {
res.render("index.ejs")
})
app.get("/hastakayit", (req, res) => {
res.render("hastakayit.ejs")
})
app.get("/doktorkayit", (req, res) => {
res.render("doktorkayit.ejs")
})
app.get("/hastalist", (req, res) => {
connection.query('SELECT * FROM hastalar', (err, results, fields)=>{
if (err){
res.send("<h1> Sunucu Tarafında bir hata oluştu </h1>" + err + "<br><a href='/'> Ana Menüye Dön </a>")
}else{
res.render("hastalist", {data:results})
}
})
})
app.get("/doktorlist", (req, res) => {
connection.query('SELECT * FROM doktorlar', (err, results, fields)=>{
if (err){
res.send("<h1> Sunucu Tarafında bir hata oluştu </h1>" + err + "<br><a href='/'> Ana Menüye Dön </a>")
}else{
res.render("doktorlist", {data:results})
}
})
})
app.get('/doktorgiris', (req, res) => {
res.render("doktorgiris", {basari: "nötr"})
console.log("get");
})
app.get("/doktorgiriskontrol", (req, res) => {
console.log("post");
connection.query('SELECT doktor_email FROM doktorlar', (err, results, fields)=>{
if (err){
res.send("<h1> Sunucu Tarafında bir hata oluştu </h1>" + err + "<br><a href='/'> Ana Menüye Dön </a>")
}else{
let requestMail = req.query.giris__doktormail
results.forEach(el => {
console.log(el.doktor_email, requestMail);
if (el.doktor_email === requestMail) {
res.render("doktorgiris", {basari: true})
}
else{
res.render("doktorgiris", {basari:false})
}
});
}
})
})
app.get("/hastagiris", (req, res) => {
res.render("hastagiris.ejs")
})
app.get('/randevukayit', (req, res) =>{
res.render("randevukayit.ejs")
})
app.listen(port,hostname, () =>{
console.log(`http://${hostname}:${port}`);
})