Adding static file handling
This commit is contained in:
parent
043b1ed7c6
commit
c1e8ee336d
2 changed files with 15 additions and 3 deletions
|
|
@ -14,6 +14,7 @@ var templates = template.Must(template.ParseFiles("tmpl/edit.html", "tmpl/view.h
|
|||
var validPath = regexp.MustCompile("^/(edit|save|view)/([a-zA-Z0-9]+)$")
|
||||
|
||||
func main() {
|
||||
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
|
||||
http.HandleFunc("/view/", makeHandler(viewHandler))
|
||||
http.HandleFunc("/edit/", makeHandler(editHandler))
|
||||
http.HandleFunc("/save/", makeHandler(saveHandler))
|
||||
|
|
|
|||
|
|
@ -1,3 +1,14 @@
|
|||
<h1>{{.Title}}</h1>
|
||||
<p>[<a href="/edit/{{.Title}}">edit</a>]</p>
|
||||
<div>{{printf "%s" .Body}}<div>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<link href="/static/css/main.css" rel="stylesheet" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>{{.Title}}</h1>
|
||||
<p>[<a href="/edit/{{.Title}}">edit</a>]</p>
|
||||
<div>{{printf "%s" .Body}}<div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Reference in a new issue