30 lines
413 B
Text
30 lines
413 B
Text
fmt := import("fmt")
|
|
paths := import("paths")
|
|
|
|
htmExt := func(c){
|
|
c.pp.print(`
|
|
<!doctype html>
|
|
<html><head>
|
|
`)
|
|
if !is_undefined(c.title) {
|
|
c.pp.printf(`<title>%s</title>`, c.title)
|
|
}
|
|
c.pp.print(`
|
|
</head><body>
|
|
`)
|
|
}
|
|
|
|
exts := {
|
|
".htm": htmExt,
|
|
".html": htmExt
|
|
}
|
|
|
|
export func(c){
|
|
url_path := c.http.request.url.path
|
|
ext := paths.ext(url_path)
|
|
|
|
cl := exts[ext]
|
|
if !is_undefined(cl) {
|
|
cl(c)
|
|
}
|
|
}
|