-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathapp.js
More file actions
49 lines (43 loc) · 890 Bytes
/
app.js
File metadata and controls
49 lines (43 loc) · 890 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
42
43
44
45
46
47
48
49
// dependencies
const express = require("express");
const app = express();
const con = require("./database.js");
app.use(express.static("public"));
app.get("/", (req, res) => {
let sql = "SELECT * FROM USERS";
con.query(
'INSERT INTO USERS (fName,lName) VALUES ("Luka","Modric")',
(err, result) => {
if (err) {
console.log(err);
}
}
);
con.query(
'INSERT INTO USERS (fName,lName) VALUES ("ANAS",BAQAI')',
(err,result)=>{
if(err){
console.log(err);
}
}
);
con.query(sql, (err, result) => {
if (err) {
console.log(err);
} else {
res.send(result);
}
});
});
// PORT
const PORT = 3000;
app.listen(PORT, () => {
console.log(`Server is running on PORT: ${PORT}`);
con.connect((err) => {
if (err) {
console.log("Error connecting to Db");
return;
}
console.log("Connected!");
});
});