-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
52 lines (35 loc) · 923 Bytes
/
app.js
File metadata and controls
52 lines (35 loc) · 923 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
50
51
/*const http = require('http');
const server = http.createServer((req, res) => {
if(req.url == "/profile"){
res.end("this is profile route")
}
if(req.url == "/about"){
res.end("this is about ")
}
});
server.listen(3000, () => {
console.log('Server is listening on port 3000');
});
*/
const express = require('express');
const morgan = require("morgan");
const app = express();
app.use(morgan('dev'));
app.use(express.json());
app.use(express.urlencoded({extended: true}))
app.use(express.static("public"))
app.set("view engine", "ejs");
app.use(function(req, res, next) {
console.log("This is middleware");
next();
});
app.get("/", function(req, res) {
res.render('index');
});
app.post("/get-form-data", function(req, res) {
console.log(req.body);
res.send("Data received");
});
app.listen(3000, () => {
console.log("Server is running on port 3000");
});