Fixup settings handling slightly
This commit is contained in:
parent
0a24eaadfa
commit
e51ba4d34d
|
@ -1,15 +1,15 @@
|
|||
import env
|
||||
import prologue
|
||||
import templating
|
||||
import env
|
||||
|
||||
proc getIndex*(ctx: Context) {.async.} =
|
||||
resp renderTemplate(templateName="index.nwt")
|
||||
|
||||
proc runWebsite() =
|
||||
let settings = newSettings(
|
||||
debug = boolEnvOrDefault("DEBUG", false)
|
||||
proc runWebsite(settings: Table) =
|
||||
let prologueSettings = newSettings(
|
||||
debug = settings["debug"]
|
||||
)
|
||||
let website = newApp(settings = settings)
|
||||
let website = newApp(settings = prologueSettings)
|
||||
|
||||
website.get("/", getIndex)
|
||||
|
||||
|
|
|
@ -8,4 +8,10 @@ proc boolEnvOrDefault(envName: string, default: bool): bool =
|
|||
else:
|
||||
return default
|
||||
|
||||
export boolEnvOrDefault
|
||||
proc strEnvOrDefault(envName: string, default: string): string =
|
||||
if existsEnv(envName):
|
||||
return getEnv(envName)
|
||||
else:
|
||||
return default
|
||||
|
||||
export boolEnvOrDefault, strEnvOrDefault
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
when isMainModule:
|
||||
import tables
|
||||
import modules/blog
|
||||
import modules/env
|
||||
|
||||
let settings = {
|
||||
"debug": boolEnvOrDefault("DEBUG", false),
|
||||
"logging": boolEnvOrDefault("NIMBLOG_LOG", true)
|
||||
}.toTable()
|
||||
|
||||
try:
|
||||
echo "Starting website"
|
||||
runWebsite()
|
||||
runWebsite(settings)
|
||||
except:
|
||||
echo "Could not run website"
|
||||
|
|
Loading…
Reference in New Issue