-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
35 lines (28 loc) · 826 Bytes
/
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
const express = require('express')
const app = express()
const nunjucks = require('nunjucks')
const path = require('path');
const moment = require('moment')
const localization = require('./locales/localization')
app.use(express.static('public'))
nunjucks.configure('views', {
express: app,
autoescape: true
})
app.set('view engine', 'html')
app.get('/:locale?/test', (req, res) => {
let locale = req.params.locale || 'en'
res.locals.l = localization[locale]
let relatedNews = [{
title: 'News one',
description: 'Olalala'
}, {
title: 'News two',
description: 'Blablabla'
}, {
title: 'News three',
description: 'Ohohoho'
}]
res.render('index', { relatedNews: relatedNews, time: moment().locale('ru').format('llll') })
})
app.listen(3009, () => console.log('Start on 3009 port'))