-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
118 lines (90 loc) · 2.91 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
app.set('views', './src/views/v-fall');
app.set('view engine', 'pug');
app.set('view cache', false);
app.use(bodyParser.json({ limit: '5mb'}));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use("/", express.static(__dirname + '/src'));
app.use(function (req, res, next) {
if (req.path.startsWith('/v-fall')) app.set('views', './src/views/v-fall');
else if (req.path.startsWith('/ladines')) app.set('views', './src/views/ladines');
else if (req.path.startsWith('/showlaxy')) app.set('views', './src/views/showlaxy');
else res.send('lolz')
next()
})
var data = [{"id": 9782, "title": "фаворитка", "year": null, "category": [], "country": null, "image": "//photo.tvigle.ru/res/2019/05/30/a211aa15-42fe-4419-8f79-1ef7514cc7aa.jpg", "url": "/video/9782"}, {"id": 9783, "title": "фаворитка 2", "year": null, "category": [], "country": null, "image": "//photo.tvigle.ru/res/2019/05/29/d8ec4e46-b5f3-4ed7-a1ac-e76d4e7f5a76.jpg", "url": "/video/9783"}]
app.get('/v-fall', function (req, res, next) {
res.render('index');
next()
});
app.get('/v-fall/error', function (req, res, next) {
res.render('error');
next()
});
app.get('/v-fall/news', function (req, res) {
res.render('news');
});
app.get('/v-fall/list', function (req, res) {
res.render('list');
});
app.get('/v-fall/inner', function (req, res) {
res.render('inner');
});
app.get('/v-fall/contacts', function (req, res) {
res.render('contacts');
});
app.get('/v-fall/article', function (req, res) {
res.render('article');
});
app.get('/ladines', function (req, res) {
res.render('index');
});
app.get('/ladines/error', function (req, res, next) {
res.render('error');
next()
});
app.get('/ladines/news', function (req, res) {
res.render('news');
});
app.get('/ladines/list', function (req, res) {
res.render('list');
});
app.get('/ladines/contacts', function (req, res) {
res.render('contacts');
});
app.get('/ladines/article', function (req, res) {
res.render('article');
});
app.get('/showlaxy', function (req, res) {
res.render('index');
});
app.get('/showlaxy/error', function (req, res, next) {
res.render('error');
next()
});
app.get('/showlaxy/news', function (req, res) {
res.render('news');
});
app.get('/fetchNews', function (req, res) {
res.setHeader('Content-Type', 'application/json');
res.setHeader('Accept', 'application/json');
res.json(JSON.stringify(data));
});
app.get('/showlaxy/list', function (req, res) {
res.render('list');
});
app.get('/showlaxy/inner', function (req, res) {
res.render('inner');
});
app.get('/showlaxy/contacts', function (req, res) {
res.render('contacts');
});
app.get('/showlaxy/article', function (req, res) {
res.render('article');
});
app.listen(3000, function () {
console.log('Rendering pug app listening on port 3000');
});