system user
This commit is contained in:
parent
11df9c4657
commit
4518b08e4d
|
@ -10,7 +10,7 @@ type
|
|||
username*: string
|
||||
|
||||
proc `$`*(t: Tweet): string =
|
||||
t.date.format(ISOTime) & "\t" & t.message
|
||||
t.date.format(ISOTime) & '\x09' & t.message
|
||||
|
||||
proc `%`*(t: Tweet): JsonNode =
|
||||
%*
|
||||
|
@ -41,6 +41,11 @@ proc parseTweet*(user, inp: string): Tweet =
|
|||
message: message,
|
||||
username: user)
|
||||
|
||||
proc fromDBRow*(r: Row): Tweet =
|
||||
Tweet(date: r[2].split(".")[0].parseInt().fromSeconds().timeToTimeInfo(),
|
||||
username: r[1],
|
||||
message: r[3])
|
||||
|
||||
proc getTweetsFrom*(url: string, username: string): seq[Tweet] =
|
||||
var res = newSeq[Tweet]()
|
||||
|
||||
|
@ -72,6 +77,8 @@ proc updateTweetsOnce*() =
|
|||
|
||||
when isMainModule:
|
||||
while true:
|
||||
try:
|
||||
updateTweetsOnce()
|
||||
except: discard
|
||||
|
||||
sleep 300_000 # 5 minutes
|
||||
|
|
|
@ -66,11 +66,18 @@ routes:
|
|||
renderMustache("home", indexTemplate, newContext())
|
||||
|
||||
get "/content/system":
|
||||
let myHeaders = {
|
||||
let
|
||||
myHeaders = {
|
||||
"Content-Type": "text/plain",
|
||||
}
|
||||
tweets = db.getAllRows(sql"select * from tweets where username='system'")
|
||||
|
||||
resp Http200, myHeaders, "hi"
|
||||
var res = ""
|
||||
|
||||
for tweet in tweets.items():
|
||||
res &= $(tweet.fromDBRow()) & "\r\n"
|
||||
|
||||
resp Http200, myHeaders, res
|
||||
|
||||
get "/timeline":
|
||||
redirect "/timeline/0"
|
||||
|
|
Loading…
Reference in New Issue