nitter/src/nitter.nim

36 lines
694 B
Nim
Raw Normal View History

2019-09-06 00:42:35 +00:00
import asyncdispatch
2019-07-31 00:15:43 +00:00
from net import Port
2019-06-20 14:16:20 +00:00
2019-09-06 00:42:35 +00:00
import jester
2019-06-24 21:25:21 +00:00
2019-09-06 00:42:35 +00:00
import types, config, prefs
import views/general
import routes/[preferences, timeline, media]
2019-06-20 14:16:20 +00:00
2019-07-31 00:15:43 +00:00
const configPath {.strdefine.} = "./nitter.conf"
let cfg = getConfig(configPath)
2019-09-06 00:42:35 +00:00
createPrefRouter(cfg)
createTimelineRouter(cfg)
createMediaRouter(cfg)
2019-07-31 00:15:43 +00:00
settings:
port = Port(cfg.port)
staticDir = cfg.staticDir
bindAddr = cfg.address
2019-06-20 14:16:20 +00:00
routes:
get "/":
2019-08-19 18:25:00 +00:00
resp renderMain(renderSearch(), Prefs(), cfg.title)
2019-06-20 14:16:20 +00:00
post "/search":
if @"query".len == 0:
2019-08-15 21:17:13 +00:00
resp Http404, showError("Please enter a username.", cfg.title)
2019-06-20 14:16:20 +00:00
redirect("/" & @"query")
2019-09-06 00:42:35 +00:00
extend preferences, ""
extend timeline, ""
extend media, ""
2019-06-20 14:16:20 +00:00
runForever()