-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
33 lines (24 loc) · 885 Bytes
/
Copy pathmain.lua
File metadata and controls
33 lines (24 loc) · 885 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
local weblit = require('weblit')
---@type function
local pathJoin = require('pathjoin').pathJoin
---@type function
local static = require('weblit-static')
-- Декоратор для кэширования запросов в RAM
local c = require('cache')
-- Периодическое обновление трека LastFM
do
local lastfm = require('models/lastfm')
local timer = require('timer')
lastfm.updateLastTrack()
timer.setInterval(15000, function()
lastfm.updateLastTrack()
end)
end
weblit.app
.bind({ host = "0.0.0.0", port = 8080 })
.use(require('weblit-logger'))
.use(require('weblit-auto-headers'))
.route({ method = "GET", path = "/" }, c(require("controllers/home")))
.route({ method = "GET", path = "/api/lastfm" }, require("controllers/lastfm"))
.use(static(pathJoin(module.dir, "assets")))
.start()