Show user list in TXT format: /users.txt
This commit is contained in:
parent
1dbe7f6f3d
commit
34d2bbe207
|
@ -1,4 +1,4 @@
|
|||
import asyncdispatch, db_sqlite, httpclient, jester, moustachu, os, shorturl,
|
||||
import asyncdispatch, db_sqlite, httpclient, jester, json, moustachu, os, shorturl,
|
||||
strutils, tables, templates/all, times, tweet/parse, twtxt, typetraits
|
||||
|
||||
let
|
||||
|
@ -122,6 +122,20 @@ routes:
|
|||
|
||||
renderMustache "users", usersTemplate, ctx
|
||||
|
||||
get "/users.txt":
|
||||
let
|
||||
headers = {
|
||||
"Content-Type": "text/plain"
|
||||
}
|
||||
users = db.getAllRows(sql"select username, url from users order by username")
|
||||
|
||||
var outBuf = ""
|
||||
|
||||
for user in users.items():
|
||||
outBuf &= "twtxt follow " & user[0] & " " & user[1] & "\r\n"
|
||||
|
||||
resp Http200, headers, outBuf
|
||||
|
||||
get "/users/@name/@page":
|
||||
try:
|
||||
var
|
||||
|
|
Loading…
Reference in New Issue