Show user list in TXT format: /users.txt

This commit is contained in:
Christine Dodrill 2016-02-12 02:29:04 -08:00
parent 1dbe7f6f3d
commit 34d2bbe207
1 changed files with 15 additions and 1 deletions

View File

@ -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