templates *do* like me after all
This commit is contained in:
parent
07d3839aa2
commit
f5534b62ff
14
server.go
14
server.go
|
@ -8,7 +8,6 @@ import (
|
||||||
"crypto/sha512"
|
"crypto/sha512"
|
||||||
"io"
|
"io"
|
||||||
"html/template"
|
"html/template"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type OutputFormatter struct {
|
type OutputFormatter struct {
|
||||||
|
@ -27,11 +26,7 @@ func startServer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func get(w http.ResponseWriter, r *http.Request) {
|
func get(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Println("rip?")
|
t, err := template.ParseFiles("templates/overview.html")
|
||||||
t := template.New("overview")
|
|
||||||
//t, err := t.ParseFiles("templates/overview.html")
|
|
||||||
|
|
||||||
t, err := t.Parse("{{.Author}} said: {{.Content}}")
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panic(err)
|
log.Panic(err)
|
||||||
|
@ -44,11 +39,8 @@ func get(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Write([]byte(post.Content))
|
w.Write([]byte(post.Content))
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
//results := readBlogpostsFromDB()
|
results := readBlogpostsFromDB()
|
||||||
//t.Execute(w, OutputFormatter{Author: results[0].Author, Content: results[0].Content})
|
err = t.ExecuteTemplate(w, "overview.html", OutputFormatter{Author: results[0].Author, Content: results[0].Content})
|
||||||
t.Execute(w, "asdasd")
|
|
||||||
t.Execute(os.Stdout, "asdasd")
|
|
||||||
//err = t.Execute(os.Stdout, OutputFormatter{Author: results[0].Author, Content: results[0].Content})
|
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<html>
|
<html>
|
||||||
<body style="background-color: #333; color: #ccc;">
|
<body style="background-color: #333; color: #ccc;">
|
||||||
<div id="content" style="width: 70%; margin: auto; padding-top: 10%;">
|
<div id="content" style="width: 70%; margin: auto; padding-top: 10%;">
|
||||||
{{.}}
|
{{.Author}} said: {{.Content}}
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
2
test.sh
2
test.sh
|
@ -5,5 +5,5 @@ else
|
||||||
msg="$1"
|
msg="$1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
curl localhost:12345/add -d "{\"content\": \"$msg\", \"Title\": \"title\", \"Secret\": \"asdf\", \"author\": \"me\"}" -H "Content-Type: application/json" -v
|
curl localhost:12345/add -d "{\"content\": \"$msg\", \"Title\": \"title\", \"Secret\": \"asdf\", \"author\": \"kageru\"}" -H "Content-Type: application/json" -v
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user