Switch to somewhat more conventional view/route split

This commit is contained in:
Quad 2022-04-11 09:03:53 +02:00
parent bc2a428432
commit ac32fa394f
2 changed files with 8 additions and 6 deletions

View File

@ -1,19 +1,17 @@
import prologue
import prologue/middlewares/staticfile
import templating
proc getIndex*(ctx: Context) {.async.} =
resp renderTemplate(templateName="index.nwt")
import views
proc runWebsite(settings: Table) =
let prologueSettings = newSettings(
debug = settings["debug"]
)
var website = newApp(settings = prologueSettings)
website.get("/", getIndex)
website.use(staticFileMiddleware("static"))
website.run()
export runWebsite

View File

@ -1,6 +1,10 @@
import prologue
import nimja/parser
proc renderTemplate(templateName: static[string]): string =
compileTemplateFile(getScriptDir() & "/templates/" & templateName)
export renderTemplate
proc getIndex*(ctx: Context) {.async.} =
resp renderTemplate(templateName="index.nwt")
export getIndex