-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
51 lines (40 loc) · 1.05 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
var express = require('express');
var app = express();
const bodyParser = require("body-parser");
app.set("view engine", "ejs");
app.use(bodyParser.urlencoded({
extended: true
}));
var port = process.env.PORT || 3000;
app.use(express.static('public'));
app.post("/data", (req, res) => {
let name = req.body.name;
let phone= req.body.phone;
let message= req.body.message;
let mail= req.body.mail;
let address=req.body.address;
let skill=req.body.skill;
if (name === "") res.redirect("/");
data={name:name,
phone:phone,
message:message,
mail:mail,
address:address,
skill:skill
};
console.log(data)
res.render("template",{data:data});
})
app.get("/", (req, res) => {
res.render("home");
});
app.get("/favicon.ico", (req, res) => {
res.render("home");
});
app.post("/favicon.ico", (req, res) => {
res.render("home");
});
app.listen(port, function(err){
if (err) console.log(err);
console.log("Server listening on PORT", port);
});