-
Notifications
You must be signed in to change notification settings - Fork 5
/
app.lua
29 lines (22 loc) · 884 Bytes
/
app.lua
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
local Emitter = require('core').Emitter
local web = require("catke/web")
local config = require("./config")
-- 错误处理
function Emitter:missingHandlerType(name, ...)
if name == 'error' then
p('=========== error ==========')
p(...)
p('=========== end ==========')
end
end
-- 加载静态目录中间件
web.use(require('catke/web/static')(config['sataic_path']))
web.use(require('catke/web/task')) -- 使用任务队列
web.use(require('./app/middlewares/init-app'))
web.route('/', require('./app/handlers/index'))
web.route('/feed', require('./app/handlers/feed'))
web.route('/page/:page', require('./app/handlers/index'))
web.route('/view/:id', require('./app/handlers/view'))
web.route('/install', require('./app/handlers/install'))
web.createServer(config):listen(config['port'])
print("Server listening at http://localhost:" .. config['port'] .. "/")