-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
65 lines (51 loc) · 1.68 KB
/
index.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
const express = require("express");
const app = express();
const cors = require("cors");
app.use(cors());
const path = require("path");
const port = process.env.PORT || 8080;
app.listen(port, () => {
console.log(`App listening on port ${port}`);
});
app.use('/img',express.static(path.join(__dirname, 'public/img')));
app.use('/js',express.static(path.join(__dirname, 'public/js')));
app.use('/css',express.static(path.join(__dirname, 'public/css')));
app.use('/lib',express.static(path.join(__dirname, 'public/lib')));
app.use('/mail',express.static(path.join(__dirname, 'public/mail')));
app.use('/scss',express.static(path.join(__dirname, 'public/scss')));
app.get("/", (req, res) => {
res.setHeader("Content-Type", "text/html");
res.sendFile(path.join(__dirname, "public/index.html"));
});
app.get("/category", (req, res) => {
res.setHeader("Content-Type", "text/html");
res.sendFile(path.join(__dirname, "category.html"));
});
app.get("/contact", (req, res) => {
res.setHeader("Content-Type", "text/html");
res.sendFile(path.join(__dirname, "contact.html"));
});
app.get("/api-get-age", (req, res) => {
res.setHeader("Content-Type", "application/json");
var d1 = req.body.day;
var m1 = req.body.month;
var y1 = req.body.year;
var date = new Date();
var d2 = date.getDate();
var m2 = 1 + date.getMonth();
var y2 = date.getFullYear();
var month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
if(d1 > d2){
d2 = d2 + month[m2 - 1];
m2 = m2 - 1;
}
if(m1 > m2){
m2 = m2 + 12;
y2 = y2 - 1;
}
var d = d2 - d1;
var m = m2 - m1;
var y = y2 - y1;
res.json({ "age" : 'Your Age is '+y+' Years '+m+' Months '+d+' Days'});
});
module.exports = app;