Switch to somewhat more conventional view/route split
This commit is contained in:
parent
bc2a428432
commit
ac32fa394f
|
@ -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
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue