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
|
||||||
import prologue/middlewares/staticfile
|
import prologue/middlewares/staticfile
|
||||||
import templating
|
import views
|
||||||
|
|
||||||
proc getIndex*(ctx: Context) {.async.} =
|
|
||||||
resp renderTemplate(templateName="index.nwt")
|
|
||||||
|
|
||||||
proc runWebsite(settings: Table) =
|
proc runWebsite(settings: Table) =
|
||||||
let prologueSettings = newSettings(
|
let prologueSettings = newSettings(
|
||||||
debug = settings["debug"]
|
debug = settings["debug"]
|
||||||
)
|
)
|
||||||
|
|
||||||
var website = newApp(settings = prologueSettings)
|
var website = newApp(settings = prologueSettings)
|
||||||
|
|
||||||
website.get("/", getIndex)
|
website.get("/", getIndex)
|
||||||
|
|
||||||
website.use(staticFileMiddleware("static"))
|
website.use(staticFileMiddleware("static"))
|
||||||
|
|
||||||
website.run()
|
website.run()
|
||||||
|
|
||||||
export runWebsite
|
export runWebsite
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
|
import prologue
|
||||||
import nimja/parser
|
import nimja/parser
|
||||||
|
|
||||||
proc renderTemplate(templateName: static[string]): string =
|
proc renderTemplate(templateName: static[string]): string =
|
||||||
compileTemplateFile(getScriptDir() & "/templates/" & templateName)
|
compileTemplateFile(getScriptDir() & "/templates/" & templateName)
|
||||||
|
|
||||||
export renderTemplate
|
proc getIndex*(ctx: Context) {.async.} =
|
||||||
|
resp renderTemplate(templateName="index.nwt")
|
||||||
|
|
||||||
|
export getIndex
|
Loading…
Reference in New Issue